Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/ROOT/pages/clauses/match.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ Returns all actors that `ACTED_IN` *'Wall Street'*.
1+d|Rows: 3
|===

Read more about xref:/syntax/expressions.adoc#relationship-type-expressions[relationship type expressions].

[[match-on-multiple-rel-types]]
=== Match on multiple relationship types
Expand Down
106 changes: 52 additions & 54 deletions modules/ROOT/pages/clauses/where.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

* xref::clauses/where.adoc#where-introduction[Introduction]
* xref::clauses/where.adoc#query-where-basic[Basic usage]
** xref::clauses/where.adoc#node-pattern-predicates[Node pattern predicates]
** xref::clauses/where.adoc#boolean-operations[Boolean operations]
** xref::clauses/where.adoc#filter-on-node-label[Filter on node label]
** xref::clauses/where.adoc#filter-on-node-property[Filter on node property]
Expand Down Expand Up @@ -40,7 +41,6 @@
** xref::clauses/where.adoc#simple-range[Simple range]
** xref::clauses/where.adoc#composite-range[Composite range]
* xref::clauses/where.adoc#pattern-element-predicates[Pattern element predicates]
** xref::clauses/where.adoc#node-pattern-predicates[Node pattern predicates]
** xref::clauses/where.adoc#relationship-pattern-predicates[Relationship pattern predicates]


Expand Down Expand Up @@ -84,6 +84,57 @@ CREATE (andy:Swedish:Person {name: 'Andy', age: 36, belt: 'white'}),
[[query-where-basic]]
== Basic usage

[[node-pattern-predicates]]
=== Node pattern predicates

`WHERE` can appear inside a node pattern in a `MATCH` clause or a pattern comprehension:


.+WHERE+
======

.Query
[source, cypher, indent=0]
----
WITH 30 AS minAge
MATCH (a:Person WHERE a.name = 'Andy')-[:KNOWS]->(b:Person WHERE b.age > minAge)
RETURN b.name
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| +b.name+
| +"Peter"+
1+d|Rows: 1
|===

======

When used this way, predicates in `WHERE` can reference the node variable that the `WHERE` clause belongs to, but not other elements of the `MATCH` pattern.

The same rule applies to pattern comprehensions.

.+WHERE+
======

.Query
[source, cypher, indent=0]
----
MATCH (a:Person {name: 'Andy'})
RETURN [(a)-->(b WHERE b:Person) | b.name] AS friends
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| +friends+
| +["Peter","Timothy"]+
1+d|Rows: 1
|===

======

[[boolean-operations]]
=== Boolean operations

Expand Down Expand Up @@ -740,59 +791,6 @@ The name and age values of nodes having a name property lexicographically betwee

`WHERE` clauses can be added to <<cypher-patterns,pattern elements>> in order to specify additional constraints.


[[node-pattern-predicates]]
=== Node pattern predicates

`WHERE` can appear inside a node pattern in a `MATCH` clause or a pattern comprehension:


.+WHERE+
======

.Query
[source, cypher, indent=0]
----
WITH 30 AS minAge
MATCH (a:Person WHERE a.name = 'Andy')-[:KNOWS]->(b:Person WHERE b.age > minAge)
RETURN b.name
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| +b.name+
| +"Peter"+
1+d|Rows: 1
|===

======

When used this way, predicates in `WHERE` can reference the node variable that the `WHERE` clause belongs to, but not other elements of the `MATCH` pattern.

The same rule applies to pattern comprehensions.

.+WHERE+
======

.Query
[source, cypher, indent=0]
----
MATCH (a:Person {name: 'Andy'})
RETURN [(a)-->(b WHERE b:Person) | b.name] AS friends
----

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| +friends+
| +["Peter","Timothy"]+
1+d|Rows: 1
|===

======


[[relationship-pattern-predicates]]
=== Relationship pattern predicates

Expand Down
Loading