Neo4j Optional Relationship Match -
i want write query returns node (a), nodes directly adjacent (b), , nodes connect (b) not nodes have been identified (b).
so... if graph was:
d / a<--b \ c
i want return { a, [b], [c, d] }.
so far, have following query (the 'prop' attribute distinguishes each node each other):
match (a)<-[:something]-(b)<-[:something*0..]<-(c) not (c.prop in b.prop) return a.prop, collect(b.prop), collect (c.prop)
if graph looks like:
a<--b
i expect result { a, [b], [] } instead nothing back, due c.prop being in b.prop. tried using optional match did not work either:
match (a)<-[:something]-(b) optional match (a)<-[:something]<-(b)<-[:something*0..]<-(c) not (c.prop in b.prop) return a.prop, collect(b.prop), collect (c.prop)
any way intended results?
when run following query:
match (n:crew)-[r:loves*]->m optional match (m:crew)-[r2:knows*]->o n.name='neo' , not (o.name in m.name) return n,m,o
in http://console.neo4j.org/, on sample graph, neo , trinity, though trinity knows nobody (o empty). think optional match needs contain actual optional part of traversal, whereas in code have everything. (a)<-[:something]<-(b)
should not appear there, (b)<-[:something*0..]<-(c)
Comments
Post a Comment