I am trying to figure out how to effectively add a new node using a cypher request. I am trying to combine multiple data sources, so you need to look for possible matching data. I have 3 data points that may or may not exist. If any of the data points match, I want to reuse an existing node. If none of the data points matches, I want to create a new node.
Creating a node, if it does not exist, is an exact precedent for MERGE. MERGE does not allow the WHERE clause, otherwise it would be pretty simple. Since I coincide with the data point - OR data-point-b OR data-point-c, I cannot figure out how to use MERGE like this, and all the properties.
This is not true, but I have to express my purpose:
MERGE (n:TYPE)
WHERE n.propertyA = "A" OR n.propertyB = "B" OR n.propertyC = "C"
ON MATCH SET n.propertyA = "A", n.propertyB = "B", n.propertyC = "C"
ON CREATE SET n.timestamp = <now>, n.propertyA = "A", n.propertyB = "B", n.propertyC = "C"
RETURN n;
I thought I could use a package or transaction. I would appreciate any understanding or guidance as I am still learning Cypher.
source
share