I'm Neo4j noob and I'm trying to create unique relationship between two nodes depending on relationship properties.
Let's say we have node A
and node B
. I would like to create a new relationship R
between A and B, if R.since = 1
or R.since IS NULL
. Otherwise I want to get an existing relationship.
I tried to do it like this:
MATCH (n:Crew { name: "Neo" }),(m:Matrix { name: "Agent Smith" })
MERGE (n)-[r:CATCH]->(m)
ON CREATE SET r.since = 1
WITH r WHERE r.since IS NULL OR r.since = 1 AND r.source = "ab"
RETURN r
but query returns nothing.
source
property on the relationship. If you remove the AND clause, you should get a result. – tstorms