I've tried a bunch of cypher queries, most coming from this question, but none worked.
E.g.:
postgres=# match (a)<-[r]-() where r is null return *;
a | r
---+---
(0 rows)
The last one I tried is this:
match (n) where not (n)<-[]-() return *
obtaining a syntax error:
postgres=# match (n) where not (n)<-[]-() return *;
ERROR: syntax error at or near ")"
LINE 1: match (n) where not (n)<-[]-() return *;
I finally fired up Neo4j and found that the above mentioned cypher query works there.
What's the equivalent in AgensGraph (2.1.3) Cypher?
NOTE
While waiting for the correct solution, I worked around the issue with the following sequence of queries:
- mark all nodes having an outgoing relation as children
match (a)<-[]-(b) SET b.child=true;
- find all non-childen nodes
match(a) where a.child is null return a;
- remove the child marking
match(a) where a.child is not null remove a.child;
Eventually wrapped within a transaction so not to alter the graph properties.