apoc.coll.duplicatesWithCount

Function APOC Core

apoc.coll.duplicatesWithCount(coll) - returns a list of duplicate items in the collection and their count, keyed by item and count (e.g., [{item: xyz, count:2}, {item:zyx, count:5}])

Signature

apoc.coll.duplicatesWithCount(coll :: LIST? OF ANY?) :: (LIST? OF ANY?)

Input parameters

Name Type Default

coll

LIST? OF ANY?

null

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;
Table 1. Results
Output
[
    {
      "count": 2,
      "item": 9
    }
]