apoc.coll.randomItems
Function APOC Core
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
Signature
apoc.coll.randomItems(coll :: LIST? OF ANY?, itemCount :: INTEGER?, allowRepick = false :: BOOLEAN?) :: (LIST? OF ANY?)
Input parameters
Name | Type | Default |
---|---|---|
coll |
LIST? OF ANY? |
null |
itemCount |
INTEGER? |
null |
allowRepick |
BOOLEAN? |
false |
Usage Examples
The following returns 2
random values from a list:
RETURN apoc.coll.randomItems([1,3,5,7,9], 2) AS output;
Output |
---|
[5, 3] |
Was this page helpful?