apoc.coll.randomItem
Syntax |
|
||
Description |
Returns a random item from the |
||
Arguments |
Name |
Type |
Description |
|
|
The list to return a random item from. |
|
Returns |
|
Usage examples
The following examples return a random value from a list using both APOC and Cypher:
apoc.coll.randomItem
RETURN apoc.coll.randomItem([1,3,5,7,9]) AS output;
Using Cypher’s rand()
WITH [1,3,5,7,9] AS list
WITH list, toInteger(rand() * size(list)) AS randomInt
RETURN list[randomInt] AS output
output |
---|
7 |