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
Copy file name to clipboardExpand all lines: modules/ROOT/pages/clauses/filter.adoc
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ RETURN n.name AS name, n.age AS age
128
128
`FILTER` and `WHERE` are both used to apply filter to queries.
129
129
However, there are a number of important differences between them that arise from the fact that `FILTER` is a clause and `WHERE` is a subclause:
130
130
131
-
* While `WHERE` should not be understood as a filter after the matching is finished (it should rather be seen as adding constraints to a described pattern), `FILTER` should be understood as performing post-match filtering, and not as adding constraints to a described patterns.
131
+
* `FILTER` acts on entities _after_ they have been matched, whereas `WHERE` constrains what rows get matched _before_ the match is performed.
132
132
* `FILTER` cannot be used within `MATCH`, `OPTIONAL MATCH`, or `WITH` clauses but only alongside them.
133
133
This means that, unlike `WHERE`, `FILTER` cannot be used to add filters inside patterns.
134
134
@@ -140,9 +140,9 @@ This `OPTIONAL MATCH` example highlights the differences between the `WHERE` sub
140
140
.`WHERE` constraining an `OPTIONAL MATCH` pattern
141
141
[source, cypher]
142
142
----
143
-
UNWIND [32,37,40] AS ages
144
-
OPTIONAL MATCH (p:Person)
145
-
WHERE p.age = ages
143
+
UNWIND [32,37,40] AS ageValue
144
+
OPTIONAL MATCH (p:Person)
145
+
WHERE p.age = ageValue
146
146
RETURN p.name AS name, p.age AS age
147
147
----
148
148
@@ -165,10 +165,10 @@ The same is not true if `WHERE` is exchanged for `FILTER`:
165
165
.`FILTER` adding post-filtering to `OPTIONAL MATCH`
166
166
[source, cypher]
167
167
----
168
-
UNWIND [32,37,40] AS ages
169
-
OPTIONAL MATCH (p:Person)
170
-
FILTER p.age = ages
171
-
RETURN p.name
168
+
UNWIND [32,37,40] AS ageValue
169
+
OPTIONAL MATCH (p:Person)
170
+
FILTER p.age = ageValue
171
+
RETURN p.name AS name, p.age AS age
172
172
----
173
173
174
174
.Result
@@ -183,7 +183,7 @@ RETURN p.name
183
183
|===
184
184
185
185
Unlike `WHERE`, `FILTER` is not part of the `OPTIONAL MATCH` and so removes entire rows from the result set based on the condition provided within the expression.
186
-
That is, when `OPTIONAL MATCH` fails to find a match and `p` is `NULL`, `FILTER p.age = ages` cannot be evaluated, causing the entire row to be removed.
186
+
That is, when `OPTIONAL MATCH` fails to find a match and `p` is `NULL`, `FILTER p.age = ageValue` cannot be evaluated, causing the entire row to be removed.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/clauses/let.adoc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,7 +186,7 @@ The fact that `LET` does not drop variables means that it can be used to chain e
186
186
.Chaining expressions: comparing `LET` and `WITH`
187
187
=====
188
188
189
-
The below query shows that variables bound by a `LET` clause be referenced by subsequent clauses without being explicitly carried over.
189
+
The below query shows that variables bound by a `LET` clause can be referenced by subsequent clauses without being explicitly carried over.
190
190
Specifically, the variable `isExpensive` is created in the first `LET` clause and referenced again in the subsequent clauses.
191
191
Note also that the variable `p`, bound in the `MATCH` clause, is available in the final `RETURN` clause despite not being referenced in any of `LET` clauses.
192
192
@@ -244,7 +244,7 @@ Unlike `WITH`, `LET` cannot perform aggregations or be combined with `DISTINCT`.
244
244
For example, in the following query, `WITH` could not be replaced by `LET`:
245
245
246
246
.Combining `WITH DISTINCT` and aggregations on expressions
247
-
[source, source]
247
+
[source, cypher]
248
248
----
249
249
MATCH (c:Customer)-[:BUYS]->(p:Product)
250
250
WITH DISTINCT c, sum(p.price) AS totalSpent
@@ -268,7 +268,7 @@ RETURN c.firstName AS customer, totalSpent
0 commit comments