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/appendix/gql-conformance/analogous-cypher.adoc
-5Lines changed: 0 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,11 +31,6 @@ These codes order the features in the table below.
31
31
| * GQL's `PERCENTILE_CONT()` function is equivalent to Cypher's xref:functions/aggregating.adoc#functions-percentilecont[`percentileCont()`] function.
32
32
* GQL's `PERCENTILE_DISC()` function is equivalent to Cypher's xref:functions/aggregating.adoc#functions-percentiledisc[`percentileDisc()`] function.
33
33
34
-
| GQ08
35
-
| `FILTER` statement
36
-
| Selects a subset of the records of the current working table.
:description: Information about Cypher's `FILTER` clause.
3
+
:table-caption!:
4
+
:page-role: new-2025.03
5
+
6
+
`FILTER` is used to add filters to queries, similar to Cypher's xref:clauses/where.adoc[`WHERE`] subclause.
7
+
Unlike `WHERE`, `FILTER` is not a subclause, which means it can be used outside of the context of the xref:clauses/match.adoc[`MATCH`], xref:clauses/optional-match.adoc[`OPTIONAL MATCH`], and xref:clauses/with.adoc[`WITH`] clauses.
Unlike `WHERE`, which relies on `MATCH`, `OPTIONAL MATCH`, or `WITH` to define its scope, `FILTER` -- being a clause rather than a subclause -- can filter queries independently of these clauses.
130
+
This can make some queries more concise.
131
+
132
+
For example, the following two queries are equivalent:
133
+
134
+
.Filter using `WITH * WHERE`
135
+
[source, cypher]
136
+
----
54
137
UNWIND [1, 2, 3, 4, 5, 6] AS x
55
138
WITH x
56
139
WHERE x > 2
57
140
RETURN x
141
+
----
58
142
59
-
same as
60
-
143
+
.Filter using `FILTER`
144
+
[source, cypher]
145
+
----
61
146
UNWIND [1, 2, 3, 4, 5, 6] AS x
62
-
FILTER > 2
147
+
FILTER x > 2
63
148
RETURN x
149
+
----
150
+
151
+
As such, `FILTER` can be seen as a substitute for the `WITH * WHERE <predicate>` constructs in Cypher.
152
+
153
+
.Using `FILTER` instead of `WITH * WHERE` in `LOAD CSV`
154
+
=====
64
155
65
-
load csv
156
+
The following two xref:clauses/load-csv.adoc[`LOAD CSV`] commands are equivalent:
LOAD CSV WITH HEADERS FROM 'file:///companies.csv' AS row
@@ -82,32 +174,48 @@ WHERE row.Id IS NOT NULL
82
174
MERGE (c:Company {id: row.Id})
83
175
----
84
176
177
+
.`LOAD CSV` using `FILTER`
85
178
[source, cypher]
86
179
----
87
180
LOAD CSV WITH HEADERS FROM 'file:///companies.csv' AS row
88
181
FILTER row.Id IS NOT NULL
89
182
MERGE (c:Company {id: row.Id})
90
183
----
91
184
185
+
=====
92
186
93
-
* Variable scope
94
-
95
-
96
-
* Filter cannot exist in patterns
97
-
187
+
[[limitations]]
188
+
== Limitations
98
189
190
+
While `FILTER` replaces `WITH * WHERE <predicate>` constructs, it does not include the ability of `WITH` to manipulate the variables in scope for subsequent clauses.
191
+
Nor can `FILTER` alias or create new variables.
192
+
In other words, `FILTER` only has the function of `WITH * WHERE <predicate>` not `WITH <selectedVariable> AS <newVariableName> WHERE <predicate>`.
99
193
194
+
Unlike `WHERE`, `FILTER` cannot be used to add filters to patterns.
100
195
196
+
.`WHERE` inside a node pattern
197
+
[source, cypher]
198
+
----
199
+
WITH 35 AS minAge
200
+
MATCH (a:Person WHERE a.name = 'Andy')-[:KNOWS]->(b:Person WHERE b.age > minAge)
MATCH (a:Person FILTER a.name = 'Andy')-[:KNOWS]->(b:Person FILTER b.age > minAge)
218
+
RETURN b.name AS name
219
+
----
104
220
105
-
106
-
107
-
108
-
109
-
== Differences between `FILTER` and `WHERE`
110
-
111
-
112
-
113
-
221
+
For more information about how to use `WHERE` in fixed-length and variable-length pattern matching, see xref:clauses/where.adoc#filter-patterns[`WHERE` -> Filter patterns].
Copy file name to clipboardExpand all lines: modules/ROOT/pages/clauses/load-csv.adoc
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -551,6 +551,9 @@ Neo4j does not store `null` values.
551
551
In the file `companies.csv`, some rows do not specify values for some columns.
552
552
The examples show several options of how to handle `null` values.
553
553
554
+
[NOTE]
555
+
The queries in this example use xref:clauses/filter.adoc#filter-with-where[`FILTER`] (introduced in Neo4j 2025.03) as a replacement for `WITH * WHERE <predicate>`.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/subqueries/subqueries-in-transactions.adoc
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -748,6 +748,9 @@ RETURN status.transactionId AS transaction, status.committed AS commitStatus, st
748
748
=====
749
749
While failed transactions may be more efficiently retried using a link:{neo4j-docs-base-uri}/create-applications[driver], below is an example how failed transactions can be retried within the same Cypher query:
750
750
751
+
[NOTE]
752
+
The query below uses xref:clauses/filter.adoc#filter-with-where[`FILTER`] (introduced in Neo4j 2025.03) as a replacement for `WITH * WHERE <predicate>`.
753
+
751
754
.Query retrying failed transactions
752
755
[source, cypher]
753
756
----
@@ -757,8 +760,7 @@ CALL (row) {
757
760
MERGE (y:Year {year: row.year})
758
761
MERGE (m)-[r:RELEASED_IN]->(y)
759
762
} IN 2 CONCURRENT TRANSACTIONS OF 10 ROWS ON ERROR CONTINUE REPORT STATUS as status
0 commit comments