apoc.coll.flattenFunctionDeprecated in 25
|
This function is deprecated.
Use Cypher’s |
Syntax |
|
||
Description |
Flattens the given |
||
Arguments |
Name |
Type |
Description |
|
|
The list to flatten. |
|
|
|
Whether nested list items should also be flattened. The default is: |
|
Returns |
|
||
Usage examples
The following flattens a collection of collections using both APOC and Cypher:
apoc.coll.flatten
RETURN apoc.coll.flatten([1,2,3,[4,5,6]]) AS output;
Cypher’s coll.flatten
RETURN coll.flatten([1,2,3,[4,5,6]]) AS output;
| Output |
|---|
[1, 2, 3, 4, 5, 6] |
The following flattens a collection of collections by a depth of one using both APOC and Cypher:
apoc.coll.flatten
RETURN apoc.coll.flatten([1,2,3,[[4,[5,6]]]]) AS output;
Using Cypher’s coll.flatten
RETURN coll.flatten([1,2,3,[[4,[5,6]]]]) AS output;
| Output |
|---|
[1, 2, 3, [4, [5, 6]]] |
The following flattens a collection of collections recursively until all levels are flattened using both APOC and Cypher:
apoc.coll.flatten
RETURN apoc.coll.flatten([1,2,3,[[4,[5,6]]]], true) AS output;
Using Cypher’s coll.flatten
RETURN coll.flatten([1,2,3,[[4,[5,6]]]], 1000) AS output;
| Output |
|---|
[1, 2, 3, 4, 5, 6] |