Collection Functions

APOC has a wide variety of Collection and List functions.

Qualified Name Type Release

apoc.coll.sum

apoc.coll.sum([0.5,1,2.3])

Function

APOC Core

apoc.coll.avg

apoc.coll.avg([0.5,1,2.3])

Function

APOC Core

apoc.coll.min

apoc.coll.min([0.5,1,2.3])

Function

APOC Core

apoc.coll.max

apoc.coll.max([0.5,1,2.3])

Function

APOC Core

apoc.coll.sumLongs

apoc.coll.sumLongs([1,3,3])

Function

APOC Core

apoc.coll.partition

apoc.coll.partition(list,batchSize)

Function

APOC Core

apoc.coll.zip

apoc.coll.zip([list1],[list2])

Function

APOC Core

apoc.coll.pairs

`apoc.coll.pairs([1,2,3]) returns [1,2],[2,3],[3,null] `

Function

APOC Core

apoc.coll.pairsMin

apoc.coll.pairsMin([1,2,3]) returns [1,2],[2,3]

Function

APOC Core

apoc.coll.toSet

apoc.coll.toSet([list]) returns a unique list backed by a set

Function

APOC Core

apoc.coll.sort

apoc.coll.sort(coll) sort on Collections

Function

APOC Core

apoc.coll.sortNodes

apoc.coll.sortNodes([nodes], 'name') sort nodes by property

Function

APOC Core

apoc.coll.sortMaps

apoc.coll.sortMaps([maps], 'name') - sort maps by property

Function

APOC Core

apoc.coll.reverse

apoc.coll.reverse(coll) - returns reversed list

Function

APOC Core

apoc.coll.contains

apoc.coll.contains(coll, value) optimized contains operation (using a HashSet) (returns single row or not)

Function

APOC Core

apoc.coll.containsAll

apoc.coll.containsAll(coll, values) optimized contains-all operation (using a HashSet) (returns single row or not)

Function

APOC Core

apoc.coll.containsSorted

apoc.coll.containsSorted(coll, value) optimized contains on a sorted list operation (Collections.binarySearch) (returns single row or not)

Function

APOC Core

apoc.coll.containsAllSorted

apoc.coll.containsAllSorted(coll, value) optimized contains-all on a sorted list operation (Collections.binarySearch) (returns single row or not)

Function

APOC Core

apoc.coll.isEqualCollection

apoc.coll.isEqualCollection(coll, values) return true if two collections contain the same elements with the same cardinality in any order (using a HashMap)

Function

APOC Core

apoc.coll.union

apoc.coll.union(first, second) - creates the distinct union of the 2 lists

Function

APOC Core

apoc.coll.unionAll

apoc.coll.unionAll(first, second) - creates the full union with duplicates of the two lists

Function

APOC Core

apoc.coll.subtract

apoc.coll.subtract(first, second) - returns unique set of first list with all elements of second list removed

Function

APOC Core

apoc.coll.removeAll

apoc.coll.removeAll(first, second) - returns first list with all elements of second list removed

Function

APOC Core

apoc.coll.intersection

apoc.coll.intersection(first, second) - returns the unique intersection of the two lists

Function

APOC Core

apoc.coll.disjunction

apoc.coll.disjunction(first, second) - returns the disjunct set of the two lists

Function

APOC Core

apoc.coll.split

apoc.coll.split(list,value) | splits collection on given values rows of lists, value itself will not be part of resulting lists

Procedure

APOC Core

apoc.coll.indexOf

apoc.coll.indexOf(coll, value) | position of value in the list

Function

APOC Core

apoc.coll.shuffle

apoc.coll.shuffle(coll) - returns the shuffled list

Function

APOC Core

apoc.coll.randomItem

apoc.coll.randomItem(coll)- returns a random item from the list, or null on an empty or null list

Function

APOC Core

apoc.coll.randomItems

apoc.coll.randomItems(coll, itemCount, allowRepick: false) - returns a list of itemCount random items from the original list, optionally allowing picked elements to be picked again

Function

APOC Core

apoc.coll.containsDuplicates

apoc.coll.containsDuplicates(coll) - returns true if a collection contains duplicate elements

Function

APOC Core

apoc.coll.duplicates

apoc.coll.duplicates(coll) - returns a list of duplicate items in the collection

Function

APOC Core

apoc.coll.duplicatesWithCount

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}])

Function

APOC Core

apoc.coll.occurrences

apoc.coll.occurrences(coll, item) - returns the count of the given item in the collection

Function

APOC Core

apoc.coll.frequencies

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

Function

APOC Core

apoc.coll.frequenciesAsMap

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})

Function

APOC Core

apoc.coll.sortMulti

apoc.coll.sortMulti(coll, ['^name','age'],[limit],[skip]) - sort list of maps by several sort fields (ascending with ^ prefix) and optionally applies limit and skip

Function

APOC Core

apoc.coll.flatten

apoc.coll.flatten(coll, [recursive]) - flattens list (nested if recursive is true)

Function

APOC Core

apoc.coll.combinations

apoc.coll.combinations(coll, minSelect, maxSelect:minSelect) - Returns collection of all combinations of list elements of selection size between minSelect and maxSelect (default:minSelect), inclusive

Function

APOC Core

apoc.coll.elements

apoc.coll.elements(list,limit,offset) yield _1,_2,..,_10,_1s,_2i,_3f,_4m,_5l,_6n,_7r,_8p - deconstruct subset of mixed list into identifiers of the correct type

Procedure

APOC Core

apoc.coll.set

apoc.coll.set(coll, index, value) | set index to value

Function

APOC Core

apoc.coll.insert

apoc.coll.insert(coll, index, value) | insert value at index

Function

APOC Core

apoc.coll.insertAll

apoc.coll.insertAll(coll, index, values) | insert values at index

Function

APOC Core

apoc.coll.remove

apoc.coll.remove(coll, index, [length=1]) | remove range of values from index to length

Function

APOC Core

apoc.coll.different

apoc.coll.different(values) - returns true if values are different

Function

APOC Core

apoc.coll.fill

apoc.coll.fill(item, count) - returns a list with the given count of items

Function

APOC Core

apoc.coll.sortText

apoc.coll.sortText(coll) sort on string based collections

Function

APOC Core

apoc.coll.pairWithOffset

apoc.coll.pairWithOffset(values, offset) - returns a list of pairs defined by the offset

Function

APOC Core