A unique identifier is a property value that distinguishes each node from every other node with the same label. Defining one prevents ambiguous matches during graph imports. section 3.1.7
Use the identifier inside MERGE so Cypher can find an existing node or create it when no matching pattern exists. Avoid treating a nonunique combination, such as name and location, as the identifier: different nodes can result. section 3.1.7
A reliable import pattern separates identity from other properties:
- MERGE the node using its label and unique identifier. section 3.1.7
- Use ON CREATE SET for properties assigned only when the node is new. section 3.1.7
- Use ON MATCH SET for properties updated when the node already exists. section 3.1.7
Merging Amy
MERGE (t:Person{name:"Amy"}) identifies the Person node by name. ON CREATE SET records location and createdAt for a new node; ON MATCH SET records updatedAt for an existing one. section 3.1.7
Listing 3.31 Cypher query that merges a node on its unique identifier property and then adds additional properties to the node
MERGE (t:Person{name:"Amy"})
ON CREATE SET t.location = "Taj Mahal", t.createdAt = datetime()
ON MATCH SET t.updatedAt = datetime()
Inspect a complete Cypher example that merges a node by its identifier and handles creation and matching separately. section 3.1.7








