lo tolmencre
lo tolmencre

Reputation: 3934

Cypher IF A AND NOT(B) in match

I want to write a cypher clause that says (I know this is not correct syntax, its just an example to show the general idea):

IF (S1)-->(B1{attr:TRUE})-->(G) AND NOT((S2)-->(B2{attr:FALSE})-->(G))
THEN stuff

So, if I have only the node B1 with attr=TRUE I want the pattern to match. If I have B1 with attr=TRUE and also B2 with attr=FALSE I want the pattern not to match. In all other cases where at least B1 with attr=TRUE is found, the mattern should match also.

But I cannot figure out how to implement this logic.

Upvotes: 0

Views: 67

Answers (1)

cybersam
cybersam

Reputation: 66967

Here is an example of how to do that:

MATCH (S1)-->(B1{attr:TRUE})-->(G)
WHERE NOT ()-->({attr:FALSE})-->(G)
... stuff ...

Or, if stuff needs to use the B2 nodes:

MATCH (S1)-->(B1{attr:TRUE})-->(G), (B2{attr:FALSE})
WHERE NOT ()-->(B2)-->(G)
... stuff ...

This should give you an idea of how to start. It all depends on what data your stuff needs to use, and how much you want to specify about the S and B nodes.

Upvotes: 1

Related Questions