Skip to content

Commit 014960d

Browse files
Josipmrdenmatea16
andauthored
Filter with pattern expressions documentation (#1425)
* Add pattern expressions * Apply suggestions from code review --------- Co-authored-by: Matea Pesic <80577904+matea16@users.noreply.github.com>
1 parent 76f50a7 commit 014960d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

pages/querying/clauses/where.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ order to avoid problems with performance or results.
2222
1.4. [Filter with node properties](#14-filter-with-node-properties)<br />
2323
1.5. [Filter with relationship properties](#15-filter-with-relationship-properties)<br />
2424
1.6. [Check if property is not null](#16-check-if-property-is-not-null)<br />
25-
1.7. [Filter with pattern expressions](#17-filter-with-pattern-expressions)<br />
25+
1.7. [Filter with EXISTS expressions](#17-filter-with-exists-expressions)<br />
26+
1.8. [Filter with pattern expressions](#18-filter-with-pattern-expressions)<br />
2627
2. [String matching](#2-string-matching)<br />
2728
3. [Regular Expressions](#3-regular-expressions)
2829
4. [Existential subqueries](#4-existential-subqueries)<br />
@@ -166,9 +167,9 @@ Output:
166167
+----------------+----------------+
167168
```
168169

169-
### 1.7. Filter with pattern expressions
170+
### 1.7. Filter with EXISTS expressions
170171

171-
Currently, we support pattern expression filters with the `exists(pattern)`
172+
Currently, we support `EXISTS` expression filters with the `exists(pattern)`
172173
function, which can perform filters based on neighboring entities:
173174

174175
```cypher
@@ -191,6 +192,30 @@ Output:
191192
+----------------+
192193
```
193194

195+
### 1.8. Filter with pattern expressions
196+
197+
Currently, we support pattern expression filters inside the `WHERE` clause.
198+
199+
```cypher
200+
MATCH (p:Person)
201+
WHERE (p)-[:LIVING_IN]->(:Country {name: 'Germany'})
202+
RETURN p.name
203+
ORDER BY p.name;
204+
```
205+
206+
Output:
207+
208+
```nocopy
209+
+----------------+
210+
| c.name |
211+
+----------------+
212+
| Anna |
213+
| John |
214+
+----------------+
215+
```
216+
217+
The pattern expressions can't contain any additional symbols that are not introduced in the previously matched symbols.
218+
194219
## 2. String matching
195220

196221
Apart from comparison and concatenation operators Cypher provides special

pages/querying/differences-in-cypher-implementations.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ Such a construct is not supported in Memgraph, but you can use `collect()` [aggr
187187

188188
{<h4 className="custom-header">Patterns in expressions</h4>}
189189
Patterns in expressions are supported in Memgraph in particular functions, like `exists(pattern)`.
190+
Memgraph also supports filtering based on patterns, like `MATCH (n) WHERE NOT (n)-->()`.
190191
In other cases, Memgraph does not yet support patterns in functions, e.g. `size((n)-->())`.
191192
Most of the time, the same functionalities can be expressed differently in Memgraph
192193
using `OPTIONAL` expansions, function calls, etc.

0 commit comments

Comments
 (0)