use-merge-to-avoid-duplicate-nodes

star 21

Use MERGE for idempotent upserts with ON CREATE and ON MATCH clauses to avoid duplicates

FalkorDB By FalkorDB schedule Updated 2/4/2026

name: Use MERGE to avoid duplicate nodes description: Use MERGE for idempotent upserts with ON CREATE and ON MATCH clauses to avoid duplicates

Use MERGE to avoid duplicate nodes

Use MERGE for idempotent upserts that create nodes only if they don't exist.

Usage

Use MERGE when you want to ensure a node exists without creating duplicates. Combine with ON CREATE and ON MATCH clauses to set properties conditionally.

Example

redis-cli GRAPH.QUERY social "MERGE (u:User {id: 42})
ON CREATE SET u.name = 'Dana'
ON MATCH SET u.last_seen = timestamp()"

Notes

  • MERGE creates the node if it doesn't exist, or matches it if it does
  • ON CREATE SET runs only when a new node is created
  • ON MATCH SET runs only when an existing node is matched
  • This ensures idempotent operations that can be safely repeated
Install via CLI
npx skills add https://github.com/FalkorDB/skills --skill use-merge-to-avoid-duplicate-nodes
Repository Details
star Stars 21
call_split Forks 2
navigation Branch main
article Path SKILL.md
More from Creator