4.10. TQL UNWIND ClauseΒΆ

The UNWIND clause expands a list of elements into a sequence of one column rows with one row for each element in the list. The following will return three rows, each with a single string value:

UNWIND ["a", "b", "c"] AS x
RETURN x

This example returns 1000 rows with a boolean true for values divisible by 3, false otherwise.

UNWIND range(0, 1000) AS x
RETURN x % 3 = 0

The UNWIND clause can also be used together with a MATCH clause to expand lists stored as properties of a frame:

MATCH (a)
UNWIND a.list AS element
RETURN element + 10

In this case, the number of rows produced, is the product of the number of matches times the number of entries in each list for each matched instance.

It is also possible to use the elements of an unwound list to drive a MATCH clause:

...
WITH a.property AS mylist
UNWIND mylist AS element
MATCH (b)
WHERE b.value >= element
RETURN count(*)