Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-18-2019 12:57 AM
Hello,
I would like to ask why a query result is different when I am using a variable length path.
for example:
MATCH (n0:I {t:'n0'})-[:rel1 *0..1]->(n1)-[:rel2 *0..1]->(n2)<-[:rel3 *0..1]-(n3) RETURN n2;
this query returns n0,n1,n2,n2,n10 nodes
but if I don't use the variable path lenght
MATCH (n0:I {t:'n0'})-[:rel1]->(n1)-[:rel2]->(n2)<-[:rel3]-(n3) RETURN n2;
the result is only n2
Is there any way to use variable length path and return only the n2 ???
Thank you
02-19-2019 04:05 PM
Using *1..1
should work the same as your second query.
Understand that by permitting a lower bound of 0, you are allowing there to be no relationship traversal at all, and that the nodes on either side of that relationship definition are allowed to be the same node.
All the sessions of the conference are now available online