Neo4j MERGE: match-or-create patterns with ON MATCH/ON CREATE
MERGE - Cypher Manual
Neo4j Cypher manual for MERGE, which binds existing patterns or creates missing ones, with constraint guidance.
Based on
The Cypher manual explains MERGE as combining MATCH and CREATE behavior on a pattern. Exact match binds the pattern; absence creates it. ON MATCH and ON CREATE attach side effects to each outcome. An example graph of Person and Movie nodes with ACTED_IN and DIRECTED relationships anchors the illustrations.
Graph application and data teams use MERGE for idempotent upserts of entities and relationships without separate existence checks. The docs advise constraints before merge so uniqueness and key rules back indexes and block unintended variants of pre-existing data.
Constraints plus MERGE encode shared shape rules at write time: what a node or relationship must look like to be the same entity. That is schema-as-governance for graph stores other systems and agents must respect.
Put this to work on CoreModels
Related connectors and recipes
Take the next step
Try CoreModels, talk with our team, or explore more resources.