MERGE
Find-or-create. If the node exists, match it. If not, create it. Safe to run multiple times -- no duplicates.
Syntax#
MERGE (variable:Label {key: value}) [RETURN variable]Examples#
Idempotent node creation#
MERGE (n:Person {name: 'Alice'}) RETURN nIf a Person node with name: 'Alice' exists, returns it. Otherwise creates it.
Idempotent data loading#
MERGE (n:Person {name: 'Alice'})
MERGE (n:Person {name: 'Bob'})
MERGE (n:Person {name: 'Carol'})Safe to run multiple times — no duplicates.
See Also#
Try it
Open ↗⌘↵ to run
Loading engine…