ON MATCH SET is an optional MERGE subclause that assigns properties when the merged pattern already exists. It is useful for recording changes without creating a duplicate node. Use a unique identifier in MERGE, then place properties that should change on a match in ON MATCH SET. section 3.1.7
Update a matched Person
MERGE (t:Person{name:"Amy"}) ON CREATE SET t.location = "Taj Mahal", t.createdAt = datetime() ON MATCH SET t.updatedAt = datetime() If Amy does not exist, MERGE creates the node and ON CREATE SET adds its initial properties. If Amy already exists, no node is created; ON MATCH SET records the current time in updatedAt. 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()
Open the complete Cypher listing for a MERGE that uses ON CREATE SET and ON MATCH SET together. section 3.1.7
