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/match.adoc
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ By applying `--`, a pattern will be matched for a relationship with any directio
148
148
149
149
.Find connected nodes using an empty relationship pattern
150
150
----
151
-
MATCH (director {name: 'Oliver Stone'})--(n)
151
+
MATCH (:Person {name: 'Oliver Stone'})--(n)
152
152
RETURN n AS connectedNodes
153
153
----
154
154
@@ -167,7 +167,7 @@ The direction of a relationship in a pattern is indicated by arrows: `-->` or `<
167
167
.Find all nodes connected to `Oliver Stone` by an outgoing relationship.
168
168
[source, cypher]
169
169
----
170
-
MATCH (:Person {name: 'Oliver Stone'})-->(movie)
170
+
MATCH (:Person {name: 'Oliver Stone'})-->(movie:Movie)
171
171
RETURN movie.title AS movieTitle
172
172
----
173
173
@@ -187,7 +187,7 @@ It is possible to introduce a variable to a pattern, either for filtering on rel
187
187
.Find the types of an aliased relationship
188
188
[source, cypher]
189
189
----
190
-
MATCH (:Person {name: 'Oliver Stone'})-[r]->(movie)
190
+
MATCH (:Person {name: 'Oliver Stone'})-[r]->()
191
191
RETURN type(r) AS relType
192
192
----
193
193
@@ -258,7 +258,7 @@ It is possible to match for a pattern containing one out of several relationship
258
258
.Relationship pattern including either `ACTED_IN` or `DIRECTED` relationship types
259
259
[source, cypher]
260
260
----
261
-
MATCH ( {title: 'Wall Street'})<-[:ACTED_IN|DIRECTED]-(person)
261
+
MATCH (:Movie {title: 'Wall Street'})<-[:ACTED_IN|DIRECTED]-(person:Person)
262
262
RETURN person.name AS person
263
263
----
264
264
@@ -283,7 +283,7 @@ A graph pattern can contain several relationship patterns.
283
283
.Graph pattern including several relationship patterns
284
284
[source, cypher]
285
285
----
286
-
MATCH (charlie {name: 'Charlie Sheen'})-[:ACTED_IN]->(movie)<-[:DIRECTED]-(director)
286
+
MATCH (:Person {name: 'Charlie Sheen'})-[:ACTED_IN]->(movie:Movie)<-[:DIRECTED]-(director:Person)
287
287
RETURN movie.title AS movieTitle, director.name AS director
288
288
----
289
289
@@ -467,10 +467,10 @@ RETURN actors.name AS actor, movieCount, collect(movies.title) AS movies
467
467
----
468
468
<1> The `Person` and `Movie` nodes matched in this step are stored in variables.
469
469
which are then passed on to the second row of the query.
470
-
<2> The `movie` variable is here implicitly imported by its occurrence in the `count()` function.
470
+
<2> The `movies` variable is here implicitly imported by its occurrence in the `count()` function.
471
471
The `WITH` clause explicitly imports the `actors` variable.
472
472
<3> An xref:clauses/order-by.adoc[`ORDER BY`] clause orders the results by `movieCount` in descending order, ensuring that the `Person` with the highest number of movies appears at the top, and xref:clauses/limit.adoc[`LIMIT] 1` ensures that all other `Person` nodes are discarded.
473
-
<4> The second MATCH clause finds all `Movie` nodes associated with the `Person` nodes currently bound to the `actors` variable.
473
+
<4> The second `MATCH` clause finds all `Movie` nodes associated with the `Person` nodes currently bound to the `actors` variable.
474
474
475
475
[NOTE]
476
476
The above query uses the xref:functions/aggregating.adoc#functions-collect[`collect()` function].
0 commit comments