apoc.coll.duplicatesWithCount

Details

Syntax

apoc.coll.duplicatesWithCount(coll)

Description

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

Arguments

Name

Type

Description

coll

LIST<ANY>

The list to collect duplicate values and their count from.

Returns

LIST<ANY>

Usage examples

The following returns duplicates in a list of maps containing an item and its count:

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