I have a relationship that is basically a linear parentage chain. A node can only have a single incoming relationship of this type. This can be arbitrarily deep, but reasonably doesn't get deeper than ~10.
example data
(a:Asset {id:1})-[:PART]->(b:Asset {id:2})->[:PART]->(c:Asset {id:3})-[:PART]->(d:Asset {id:4})...
Given any node, I need to be able to return it's lineage all the way up to the top. However I need it to be ordered.
This query does the trick well:
MATCH (:Asset {id: '3'})<-[:PART*0..20]-(a:Asset)
RETURN a.id;
This returns me:
3
2
1
What I'm wondering is the order of this response guaranteed to be visit order?
Empirically I cannot find a result that is out of order, but I want to make sure that order is stable or find a different way to ensure the stable order.
Just to double check if I understood your comment correctly Andrew. For simple queries it's sufficient to rely on the fact that variable path matching is done using DFS. So in our project we create paths of trains for example, which are sequences of "TrackingPoint"'s being connected with each other through a "NEXT" relation. So if we would want to query the list of Tracking Point nodes in order (any order, as long as it is consistent) in between 2 given Tracking Points, then following query would be sufficient?
MATCH p = (startTP:TrackingPoint{id: 1})-[:NEXT*]->(endTP:TrackingPoint{id: 2})
return nodes(p)
If I understood your explanation correctly it might only become a problem when we start combining different types of nodes, where different indexes on these node types might influence what is used by the query planner as a starting node? (so in our case this wouldn't present any issue?)
Many thanks for any additional explanation or confirmation. This type of querying is quite significant to the success of our project.