apoc.coll.frequenciesAsMap

Function APOC Core

apoc.coll.frequenciesAsMap(coll) - return a map of frequencies of the items in the collection, key item, value count (e.g., {1:2, 2:1})

Signature

apoc.coll.frequenciesAsMap(coll :: LIST? OF ANY?) :: (MAP?)

Input parameters

Name Type Default

coll

LIST? OF ANY?

null

Usage Examples

The following returns a map containing each item and their frequency in a collection:

RETURN apoc.coll.frequenciesAsMap([1,3,5,7,9,9]) AS output;
Table 1. Results
Output
{
  "1": 1,
  "3": 1,
  "5": 1,
  "7": 1,
  "9": 2
}