Get all Nodes that don't have a specific relationship in Neo4j

Viewed 3534

I am trying to get all Nodes (node1) that have relationship (relationship of type R1) to node2 and not having (relationship of type R2). I tried to run this query :

MATCH  node1 -[r1: R1]-> node2 WHERE node2.id = '1234' WITH node1,node2
OPTIONAL MATCH  node1- [r2: R2]->node2 WHERE r2 is NULL 
RETURN content 

I am stil getting nodes that have r2 relationship in the resulte. what is wrong with my query?

1 Answers
Related