apoc.map.mergeList

Function

apoc.map.mergeList(maps LIST<MAP<STRING, Value>>) - merges all MAP values in the given LIST<MAP<STRING, ANY>> into one MAP.

Signature

apoc.map.mergeList(maps :: LIST<MAP>) :: MAP

Input parameters

Name Type Default

maps

LIST<MAP>

null

Usage Examples

The following merges multiple maps:

RETURN apoc.map.mergeList([
    {name: "Cristiano Ronaldo"},
    {dob: date("1985-02-05")},
    {country: "Portugal"}
]) AS output;
Table 1. Results
Output
{
  "name": "Cristiano Ronaldo",
  "country": "Portugal",
  "dob": "1985-02-05"
}

apoc.map.mergeList iterates over the list sequentially as it merges. This means that if the same key is used for different values, the last unique key-value pair in the list will be in the resulting map.

RETURN apoc.map.mergeList([
    {name: "Cristiano Ronaldo"},
    {dob: date("1985-02-05")},
    {profession: "Athlete"},
    {profession: "Football player"}
]) AS output;
Table 2. Results
Output
{
  "name": "Cristiano Ronaldo",
  "profession": "Football player",
  "dob": "1985-02-05"
}