Reputation: 41
I start to learn neo4j. I am using the graph
and I have a problem. I do not know how to get all the connections from Darjeeling
to Sandakphu
. All queries return invalid input or no rows.
Could anyone see how should be build correct query?
1)This is correct
MATCH (p:peak{name:'Sandakphu'})-[r:twowheeler*]-(t:town{name:'Rimbik'}) return distinct(r)
What's wrong with this one if I want all routes
MATCH (p:peak{name:'Sandakphu'})-[r:*]-(t:town{name:'Darjeeling'}) return distinct(r)
2) This is correct
MATCH (a:village { name: 'Sirikhola' }),(b:village{ name: 'Gurdum' }) MATCH (a)-[r]->(b) RETURN r
With this
MATCH (a:village { name: 'Sirikhola' }),(b:town{ name: 'Darjeeling' }) MATCH (a)-[r]->(b) RETURN r
i have no rows
Upvotes: 3
Views: 5092
Reputation: 19373
In the second case, there appears to be no path of length 1 between Sirikhola and Darjeeling, and so the query returns nothing. Try putting a reasonable upper bound for the max hops:
MATCH (a:village{name:'Sirikhola'})-[r*..5]-(t:town{name:'Darjeeling'})
return r
The first query should also work (I've added an upper bound instead of leaving it unconstrained):
MATCH (p:peak{name:'Sandakphu'})-[r*..5]-(t:town{name:'Darjeeling'})
return r
BTW you can consider using allShortestPaths
Upvotes: 3