Reputation: 1581
I have the following NEO4J query, which doesn't return anything:
MATCH (:TimetreeRoot)-[:CHILD]->(year:Year)-[:CHILD]->(month:Month)-[:CHILD]->(day:Day)
WHERE year.value = 2016 AND month.value = 4 AND day.value = 26
MATCH (day)-[:CHILD]->(bhour:Hour)-[:CHILD]->(bminute:Minute)
WHERE bhour.value = 8 and bminute.value = 0
MATCH (day)-[:CHILD]->(ehour:Hour)-[:CHILD]->(eminute:Minute)
WHERE ehour.value = 18 AND eminute.value = 0
MATCH p=shortestPath((bminute)-[:NEXT*]->(eminute))
RETURN collect(NODES(p))
When the difference is smaller (say bhour 12 and ehour 18), i.e. less NEXT
relationships to traverse, it does work.
It also works, when I set the nr of hops explicitly:
MATCH p=shortestPath((bminute)-[:NEXT*1..48]->(eminute))
So I can get it to work correctly, but my question is: why do I need to set the nr of maxHops? From the manual:
minHops and maxHops are optional and default to 1 and infinity respectively http://neo4j.com/docs/stable/query-match.html#match-variable-length-relationships
It's not necessarily a big deal, since I did figure out how to get it to work. However, I'd like to understand what's causing this problem.
Upvotes: 2
Views: 115
Reputation: 20185
The shortestPath has a default max hops of 15 hops. This is why you need to specify it if you want to exceed this default.
From the documentation :
find a single shortest path between two nodes, as long as the path is max 15 relationships long
Upvotes: 3