I am trying to figure out how to efficiently add a new node using a cypher query. I am trying to merge multiple data sources, so 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 do reuse the existing node. If none of the data points match, I want to create a new node.
Creating the node if it does not exist is the exact use case for MERGE. MERGE does not allow a WHERE clause otherwise this would be pretty simple. Since I am matching data-point-a OR data-point-b OR data-point-c, I can't figure out how to use MERGE as it AND's all the properties.
This is not valid, but should express my goal:
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 was thinking I might be able to use a batch or transaction. I would appreciate any insight or guidance as I am still learning Cypher.