I've followed the following guide to find a longest path when a single relationship is at play Achieving longestPath Using Cypher - Knowledge Base.
However my model, of DNS resolution, looks like the following:
(Host)-[ALIAS_FOR]->(DNSRecord)-[RESOLVES_TO]->(Host)
Any host outside of our DNS is the final destination e.g. a heroku app or S3 bucket.
I want to write a query that, given a host, traverses as far as the final host that does not have an ALIAS_FOR
relationship.
There is the simple case of non-bifurcating chains, but there is also the bifurcating case to consider (for geo-specific DNS routing a host may be an alias for multiple DNSRecord
s).
As a nice to have, it'd be good if it could handle chains of length 1 (i.e. the Host provided has no ALIAS_FOR
relationship)
The only way of tackling this problem I can think of is APOC virtual relationships https://neo4j.com/docs/labs/apoc/current/virtual/, but I wonder if there is a native cypher way?