How is it possible in cypher to have a query like: "return all people that anna follows that don't follow anyone"?
In the following (where I have the id of the start node made clear after the query) the "r is null"-part does not seem to work:
START o=node({id})
MATCH (a)-[:follows]->(b)-[r]->(c)
WHERE a.name="anna" and r is null
RETURN b
Right now, "follows" is the only relation I have. But also
START o=node({id})
MATCH (a)-[:follows]->(b)-[:follows]->(c)
WHERE a.name="anna" and c is null
RETURN b* does not work.
By doesn't work I mean: I don't get any results although there should be some.
It won't match
a pattern if it doesn't exist. match
is for finding things, not for not finding things. You can put a predicate like that into the where
clause:
START a=node({id})
MATCH (a)-[:follows]->(b)
WHERE not(b-[:follows]->())
RETURN b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With