Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-08-2018 01:29 AM
Hello,
I have a Cypher query as follows : MATCH p = (n {t='toto'})-->(n1)-[y]->(n2)-[z]->(n3) RETURN p;
This query works fine for "complete" paths but in my case I am no sure if relations x,y,z exists.
I would like to ask, if there is a way to have OPTIONAL segments inside of the path so I won't get a null if there is a segment missing but all the path until the missing segment.
I guess solution can be OPTIONAL MATCH p0 = (n {t='toto'})-->(n1) OPTIONAL MATCH p1=(n1)-[y]->(n2) OPTIONAL MATCH p2=(n2)-[z]->(n3) RETURN p0,p1,p2 but I want to know if there is a better way of not splitting the path in multiple blocks.
Thank you
Solved! Go to Solution.
11-08-2018 01:51 AM
you could use quantifiers:
MATCH p = (n {t='toto'})-->(n1)-[y*0..1]->(n2)-[z*0..1]->(n3) RETURN p;
11-08-2018 01:51 AM
you could use quantifiers:
MATCH p = (n {t='toto'})-->(n1)-[y*0..1]->(n2)-[z*0..1]->(n3) RETURN p;
All the sessions of the conference are now available online