apoc.map.groupByMulti

Function APOC Core

apoc.map.groupByMulti([maps/nodes/relationships],'key') yield value - creates a map of the list keyed by the given property, with list values

Signature

apoc.map.groupByMulti(values :: LIST? OF ANY?, key :: STRING?) :: (MAP?)

Input parameters

Name Type Default

values

LIST? OF ANY?

null

key

STRING?

null

Usage Examples

The following creates a map keyed by club, with list values:

RETURN apoc.map.groupByMulti([
	{name: "Cristiano Ronaldo", club: "Juventus"},
    {name: "Lionel Messi", club: "Barcelona"},
    {name: "Aaron Ramsey", club: "Juventus"},
    {name: "Luiz Suarez", club: "Barcelona"}
], "club") AS output;
Table 1. Results
Output
{
    "Juventus": [
      {
        "name": "Cristiano Ronaldo",
        "club": "Juventus"
      },
      {
        "name": "Aaron Ramsey",
        "club": "Juventus"
      }
    ],
    "Barcelona": [
      {
        "name": "Lionel Messi",
        "club": "Barcelona"
      },
      {
        "name": "Luiz Suarez",
        "club": "Barcelona"
      }
    ]
  }