Finding nodes that do not have specific relationship (Cypher/neo4j) Finding nodes that do not have specific relationship (Cypher/neo4j) database database

Finding nodes that do not have specific relationship (Cypher/neo4j)


That would be

MATCH (a:Foo) WHERE not ((a)-[:has]->(:Bar)) RETURN a;


This also works if you're looking for all singletons/orphans:

MATCH (a:Foo) WHERE not ((a)--()) RETURN a;