You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -269,13 +275,15 @@ RETURN [(a)-[r:KNOWS WHERE r.since < minYear]->(b:Person) | r.since] AS years
269
275
If matching for variable length patterns, `WHERE` can only be used together with the xref:patterns/variable-length-patterns.adoc#quantified-path-patterns[quantified path pattern] or xref:patterns/variable-length-patterns.adoc#quantified-relationships[quantified relationships] syntax.
270
276
271
277
.Allowed - `WHERE` predicate inside a quantified relationship
278
+
// tag::clauses_where_var_length[]
272
279
[source, cypher]
273
280
----
274
281
MATCH p = (a:Person {name: "Andy"})-[r:KNOWS WHERE r.since < 2011]->{1,4}(:Person)
275
282
RETURN [n IN nodes(p) | n.name] AS paths
276
283
----
284
+
// end::clauses_where_var_length[]
277
285
278
-
Note that any path´s including `Timothy` and `Susan` are excluded by the `WHERE` predicate, since their incoming `KNOWS` relationships both have a `since` value that is higher than `2011.`
286
+
Note that any paths including `Timothy` and `Susan` are excluded by the `WHERE` predicate, since their incoming `KNOWS` relationships both have a `since` value that is higher than `2011.`
@@ -210,13 +218,15 @@ RETURN list[2..4] AS middleElements,
210
218
Negative indexing in list slicing references elements from the end of the `LIST`; `..-1` excludes the last element, `..-2` excludes the last two elements, and so on.
@@ -251,11 +261,13 @@ RETURN nestedList[0..2] AS slicedNestedList
251
261
Slicing inner `LIST` values require two `[]` operators; the first `[]` accesses elements from the outer `LIST`, while the second slices or accesses elements from the inner `LIST`.
252
262
253
263
.Slice inner `LIST`
264
+
// tag::expressions_list_slice_inner_list[]
254
265
[source, cypher]
255
266
----
256
267
WITH [[1, 2, 3], [4, 5, 6], [7, 8, 9]] AS nestedList
@@ -498,13 +516,15 @@ RETURN [listIndex IN range(0, size(list)-1) | toString(listIndex) || ': ' || toS
498
516
The below query iterates over the `skills` property of each `Person` node and creates a new `LIST` by xref:expressions/string-operators.adoc[concatenating the `STRING`] `" expert"` to each element in `skills`.
499
517
500
518
.Modify `LIST` properties using list comprehension
The next query uses the xref:functions/aggregating.adoc#functions-collect[`collect()`] function to gather all `Person` nodes into a `LIST`, and the `WHERE 'Python' IN person.skills` predicate filters that list to include only those nodes whose `skills` property contains `Python`.
525
545
526
546
.List comprehension with a `WHERE` predicate
547
+
// tag::expressions_list_comprehension_where[]
527
548
[source, cypher]
528
549
----
529
550
MATCH (p:Person)
530
551
RETURN [person IN collect(p) WHERE 'Python' IN person.skills | person.name] AS pythonExperts
@@ -572,11 +596,13 @@ Pattern comprehension is used to create new `LIST` values by matching graph patt
572
596
The below query retrieves a list of names of people who work for `Alice` by using pattern comprehension extract the names of `employees` into a `LIST`.
573
597
574
598
.Pattern comprehension on a fixed-length pattern
599
+
// tag::expressions_list_pattern_comprehension[]
575
600
[source, cypher]
576
601
----
577
602
MATCH (alice:Person {name: 'Alice'})
578
603
RETURN [(employee:Person)-[:WORKS_FOR]->(alice) | employee.name] AS employees
@@ -622,6 +650,7 @@ The below query uses a pattern comprehension to collect the skills of all superi
622
650
The xref:functions/list.adoc#functions-reduce[`reduce()`] function concatenates these skills into a single `LIST`, and xref:clauses/unwind.adoc[`UNWIND`] is used to flatten this `LIST` before returning the distinct skills in a new `LIST`.
623
651
624
652
.Allowed: variable-length pattern comprehension using variable-length relationship syntax
0 commit comments