apoc.map.merge

Details

Syntax

apoc.map.merge(map1, map2)

Description

Merges the two given MAP values into one MAP.

Arguments

Name

Type

Description

map1

MAP

The first map to merge with the second map.

map2

MAP

The second map to merge with the first map.

Returns

MAP

Usage examples

The following merges two maps:

apoc.map.merge
WITH {name: "Cristiano Ronaldo", dob: date("1985-02-05")} AS map1, {country: "Portugal"} AS map2
RETURN apoc.map.merge(map1, map2) AS output;
Cypher’s Map Comprehension
WITH {name: "Cristiano Ronaldo", dob: date("1985-02-05")} AS map1, {country: "Portugal"} AS map2
RETURN { k IN keys(map1) + keys(map2) | k: coalesce(map2[k], map1[k]) } AS output;
Results
Output
{
  "name": "Cristiano Ronaldo",
  "country": "Portugal",
  "dob": "1985-02-05"
}