apoc.coll.frequencies

Details

Syntax

apoc.coll.frequencies(coll)

Description

Returns a LIST<ANY> of frequencies of the items in the collection, keyed by item and count.

Arguments

Name

Type

Description

coll

LIST<ANY>

The list to return items and their count from.

Returns

LIST<ANY>

Usage examples

The following returns a list of maps containing each item and their frequency in a collection:

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