I ran into a problem today understanding OPTIONAL MATCH clause in cypher. Let's consider this simple case:
CREATE (:a {type:"group"})-[:a_rel]->(:a {type: "app"})-[:b_rel]->(:b);
This creates 2 "a" node with different type attribute, plus one "b" node. All of them are in a simple path a-->a-->b
Then, I'm trying to match the "a" node having "group" type, connected to the other "a" node, optionaly connected to the "b" node.
So, if I run the following query, I expect it to return nothing:
MATCH(x:a)-->(y:a)
where x.type = "group"
OPTIONAL MATCH (y)-->(z:b)
where z IS NULL
return y
but it always return the second "a" node of the path, using IS NULL or IS NOT NULL on the where clause.
Could you please explain me what I do not understand here. In my real model, the second "a" node can be connected or not to the "b" node. I would like to retrieve all the one that are not connected to any "b" node.
Thanks a lot for your help
Rémi