['a', 'b', 'c'] AS list

Literal lists are declared in square brackets.

size($list) AS len, $list[0] AS value

Lists can be passed in as parameters.

range($firstNum, $lastNum, $step) AS list

range() creates a list of numbers (step is optional), other functions returning lists are: labels(), nodes(), relationships().

MATCH p = (a)-[:KNOWS\*]->()
RETURN relationships(p) AS r

The list of relationships comprising a variable length path can be returned using named paths and relationships().

RETURN matchedNode.list[0] AS value,
       size(matchedNode.list) AS len

Properties can be lists of strings, numbers or booleans.

list[$idx] AS value,
list[$startIdx..$endIdx] AS slice

List elements can be accessed with idx subscripts in square brackets. Invalid indexes return null. Slices can be retrieved with intervals from start_idx to end_idx, each of which can be omitted or negative. Out of range elements are ignored.

UNWIND $names AS name
MATCH (n {name: name})
RETURN avg(n.age)

With UNWIND, any list can be transformed back into individual rows. The example matches all names from a list of names.

MATCH (a)
RETURN [(a)-->(b) WHERE b.name = 'Bob' | b.age]

Pattern comprehensions may be used to do a custom projection from a match directly into a list.

MATCH (person)
RETURN person { .name, .age}

Map projections may be easily constructed from nodes, relationships and other map values.

Comments