Skip to content

Commit 5660d45

Browse files
rsill-neo4jJPryce-Aklundh
authored andcommitted
fixes
1 parent c2fda95 commit 5660d45

File tree

15 files changed

+133
-8
lines changed

15 files changed

+133
-8
lines changed

modules/ROOT/pages/clauses/finish.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
[[query-finish]]
33
= FINISH
44

5-
A query ending in `FINISH` instead of `RETURN` has no result but executes all its side effects.
5+
A query ending in `FINISH` -- instead of `RETURN` -- has no result but executes all its side effects.
66
`FINISH` was introduced as part of Cypher's xref:appendix/gql-conformance/index.adoc[].
77

88
The following read query successfully executes but has no results:
99

1010
.Query
11+
// tag::clauses_finish_match[]
1112
[source, cypher]
1213
----
1314
MATCH (p:Person)
1415
FINISH
1516
----
17+
// end::clauses_finish_match[]
1618

1719
The following query has no result but creates one node with the label `Person`:
1820

modules/ROOT/pages/clauses/foreach.adoc

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ CREATE
3333
[[foreach-mark-all-nodes-along-a-path]]
3434
== Mark all nodes along a path
3535

36-
This query will set the property `marked` to `true` on all nodes along a path.
36+
This query sets the property `marked` to `true` on all nodes along a path.
3737

3838
.Query
39+
// tag::clauses_foreach_node[]
3940
[source, cypher, indent=0]
4041
----
4142
MATCH p=(start)-[*]->(finish)
4243
WHERE start.name = 'A' AND finish.name = 'D'
4344
FOREACH (n IN nodes(p) | SET n.marked = true)
4445
----
46+
// end::clauses_foreach_node[]
4547

4648
.Result
4749
[role="queryresult",options="footer",cols="1*<m"]
@@ -51,3 +53,47 @@ d|Rows: 0 +
5153
Properties set: 4
5254
|===
5355

56+
57+
[[foreach-mark-all-relationships-along-a-path]]
58+
== Mark all relationships along a path
59+
60+
This query sets the property `marked` to `true` on all relationships along a path.
61+
62+
// tag::clauses_foreach_relationship[]
63+
[source, cypher, indent=0]
64+
----
65+
MATCH p=(start)-[*]->(finish)
66+
WHERE start.name = 'A' AND finish.name = 'D'
67+
FOREACH ( r IN relationships(p) | SET r.marked = true )
68+
----
69+
// end::clauses_foreach_relationship[]
70+
71+
.Result
72+
[role="queryresult",options="footer",cols="1*<m"]
73+
|===
74+
|(empty result)
75+
d|Rows: 0 +
76+
Properties set: 3
77+
|===
78+
79+
[[foreach-create-new-nodes-form-a-list]]
80+
== Create new nodes from a list of name labels
81+
82+
This query creates a new node for each label in a list.
83+
84+
.Query
85+
// tag::clauses_foreach_create[]
86+
[source, cypher, indent=0]
87+
----
88+
WITH ['E', 'F', 'G'] AS names
89+
FOREACH ( value IN names | CREATE (:Person {name: value}) )
90+
----
91+
// end::clauses_foreach_create[]
92+
93+
.Result
94+
[role="queryresult",options="footer",cols="1*<m"]
95+
|===
96+
1+|(empty result)
97+
1+d|Rows: 0 +
98+
Nodes created: 3
99+
|===

modules/ROOT/pages/clauses/limit.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,14 @@ Properties set: 1
166166
`LIMIT` can be used as a standalone clause, or in conjunction with xref:clauses/order-by.adoc[`ORDER BY`] or xref:clauses/skip.adoc[`SKIP`]/xref:clauses/skip.adoc#offset-synonym[`OFFSET`].
167167

168168
.Standalone use of `LIMIT`
169+
// tag::clauses_limit_standalone[]
169170
[source, cypher]
170171
----
171172
MATCH (n)
172173
LIMIT 2
173174
RETURN collect(n.name) AS names
174175
----
176+
// end::clauses_limit_standalone[]
175177

176178
.Result
177179
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -185,6 +187,7 @@ The following query orders all nodes by `name` descending, skips the two first r
185187
It then xref:functions/aggregating.adoc#functions-collect[collects] the results in a list.
186188

187189
.`LIMIT` used in conjunction with `ORDER BY` and `SKIP`
190+
// tag::clauses_limit[]
188191
[source, cypher]
189192
----
190193
MATCH (n)
@@ -193,6 +196,7 @@ SKIP 2
193196
LIMIT 2
194197
RETURN collect(n.name) AS names
195198
----
199+
// end::clauses_limit[]
196200

197201
.Result
198202
[role="queryresult",options="header,footer",cols="1*<m"]

modules/ROOT/pages/clauses/load-csv.adoc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ By default, paths are resolved relative to the Neo4j import directory.
4646
----
4747
4848
.Query
49+
// tag::clauses_load_csv_local_files[]
4950
[source, cypher]
5051
----
5152
LOAD CSV FROM 'file:///artists.csv' AS row
5253
MERGE (a:Artist {name: row[1], year: toInteger(row[2])})
5354
RETURN a.name, a.year
5455
----
56+
// end::clauses_load_csv_local_files[]
5557
5658
.Result
5759
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -112,12 +114,14 @@ However, this means that insecure URLs on virtual hosts will not function unless
112114
----
113115
114116
.Query
117+
// tag::clauses_load_csv_remote_locations[]
115118
[source, cypher]
116119
----
117120
LOAD CSV FROM 'https://data.neo4j.com/bands/artists.csv' AS row
118121
MERGE (a:Artist {name: row[1], year: toInteger(row[2])})
119122
RETURN a.name, a.year
120123
----
124+
// end::clauses_load_csv_remote_locations[]
121125
122126
.Result
123127
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -702,9 +706,11 @@ person_tmdbId,bio,born,bornIn,died,person_imdbId,name,person_poster,person_url
702706
----
703707
704708
[NOTE]
705-
The below query uses a xref:subqueries/call-subquery.adoc#variable-scope-clause[variable scope clause] to import variables into the `CALL` subquery.
709+
The query below uses a xref:subqueries/call-subquery.adoc#variable-scope-clause[variable scope clause] (introduced in Neo4j 5.23) to import variables into the `CALL` subquery.
710+
If you are using an older version of Neo4j, use an xref:subqueries/call-subquery.adoc#importing-with[importing `WITH` clause] instead.
706711
707712
.Query
713+
// tag::clauses_load_csv_transactions[]
708714
[source, cypher]
709715
----
710716
LOAD CSV WITH HEADERS FROM 'https://data.neo4j.com/importing-cypher/persons.csv' AS row
@@ -713,6 +719,7 @@ CALL (row) {
713719
SET p.name = row.name, p.born = row.born
714720
} IN TRANSACTIONS OF 200 ROWS
715721
----
722+
// end::clauses_load_csv_transactions[]
716723
717724
.Result
718725
[source, role="queryresult"]
@@ -747,11 +754,13 @@ A common use case for this function is to generate sequential unique IDs for CSV
747754
----
748755
749756
.Query
757+
// tag::clauses_load_csv_linenumber[]
750758
[source, cypher]
751759
----
752760
LOAD CSV FROM 'file:///artists.csv' AS row
753761
RETURN linenumber() AS number, row
754762
----
763+
// end::clauses_load_csv_linenumber[]
755764
756765
.Result
757766
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -782,11 +791,13 @@ The xref:functions/load-csv.adoc#functions-file[`file()`] function provides the
782791
----
783792
784793
.Query
794+
// tag::clauses_load_csv_file[]
785795
[source, cypher, role=test-result-skip]
786796
----
787797
LOAD CSV FROM 'file:///artists.csv' AS row
788798
RETURN DISTINCT file() AS path
789799
----
800+
// end::clauses_load_csv_file[]
790801
791802
.Result
792803
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -833,6 +844,7 @@ Id,Name,Year
833844
----
834845
835846
.Query
847+
// tag::clauses_load_csv_headers[]
836848
[source, cypher]
837849
----
838850
LOAD CSV WITH HEADERS FROM 'file:///artists-with-headers.csv' AS row
@@ -841,6 +853,7 @@ RETURN
841853
a.name AS name,
842854
a.year AS year
843855
----
856+
// end::clauses_load_csv_headers[]
844857
845858
.Result
846859
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -876,11 +889,13 @@ If you try to import a file that doesn't use `,` as field delimiter and you also
876889
----
877890
878891
.Query
892+
// tag::clauses_load_csv_field_terminator[]
879893
[source, cypher]
880894
----
881895
LOAD CSV FROM 'file:///artists-fieldterminator.csv' AS row FIELDTERMINATOR ';'
882896
MERGE (:Artist {name: row[1], year: toInteger(row[2])})
883897
----
898+
// end::clauses_load_csv_field_terminator[]
884899
885900
.Result
886901
[source, role="queryresult"]

modules/ROOT/pages/clauses/match.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ For more information about finding node patterns, see xref:patterns/fixed-length
4545
By specifying a pattern with a single node and no labels, all nodes in the graph will be returned.
4646

4747
.Find all nodes in a graph
48+
// tag::clauses_match_all_nodes[]
4849
[source, cypher]
4950
----
5051
MATCH (n)
5152
RETURN n
5253
----
54+
// end::clauses_match_all_nodes[]
5355

5456
.Result
5557
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -70,11 +72,13 @@ RETURN n
7072
=== Find nodes with a specific label
7173

7274
.Find all nodes with the `Movie` label
75+
// tag::clauses_match_label[]
7376
[source, cypher]
7477
----
7578
MATCH (movie:Movie)
7679
RETURN movie.title
7780
----
81+
// end::clauses_match_label[]
7882

7983
.Result
8084
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -189,11 +193,13 @@ RETURN movie.title AS movieTitle
189193
It is possible to introduce a variable to a pattern, either for filtering on relationship properties or to return a relationship.
190194

191195
.Find the types of an aliased relationship
196+
// tag::clauses_match_relationship_types[]
192197
[source, cypher]
193198
----
194199
MATCH (:Person {name: 'Oliver Stone'})-[r]->()
195200
RETURN type(r) AS relType
196201
----
202+
// end::clauses_match_relationship_types[]
197203

198204
[NOTE]
199205
The above query uses the xref:functions/scalar.adoc#functions-type[`type()` function].
@@ -238,11 +244,13 @@ RETURN a, b
238244
It is possible to specify the type of a relationship in a relationship pattern by using a colon (`:`) before the relationship type.
239245

240246
.Relationship pattern filtering on the `ACTED_IN` relationship type
247+
// tag::clauses_match_relationship[]
241248
[source, cypher]
242249
----
243250
MATCH (:Movie {title: 'Wall Street'})<-[:ACTED_IN]-(actor:Person)
244251
RETURN actor.name AS actor
245252
----
253+
// end::clauses_match_relationship[]
246254

247255
.Result
248256
[source, role="queryresult",options="header,footer",cols="1*<m"]
@@ -391,11 +399,13 @@ For more information about how to set parameters, see xref:syntax/parameters.ado
391399
The `MATCH` clause can also be used to bind whole paths to variables.
392400

393401
.Find all paths matching a pattern
402+
// tag::clauses_match_path[]
394403
[source, cypher]
395404
----
396405
MATCH path = ()-[:ACTED_IN]->(movie:Movie)
397406
RETURN path
398407
----
408+
// end::clauses_match_path[]
399409

400410
.Result
401411
[role="queryresult",options="header,footer",cols="1*<m"]

modules/ROOT/pages/clauses/optional-match.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ This is because the second `MATCH` clause returns no data (there are no `DIRECTE
7979
However, replacing the second `MATCH` clause with `OPTIONAL MATCH` does return results.
8080
This is because, unlike `MATCH`, `OPTIONAL MATCH` enables the value `null` to be passed between clauses.
8181

82+
// tag::clauses_optional_match[]
8283
[source, cypher]
8384
----
8485
MATCH (p:Person {name: 'Martin Sheen'})
8586
OPTIONAL MATCH (p)-[r:DIRECTED]->()
8687
RETURN p.name, r
8788
----
89+
// end::clauses_optional_match[]
8890

8991
.Result
9092
[role="queryresult",options="header,footer",cols="2*<m"]

modules/ROOT/pages/clauses/order-by.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ CREATE
3939
`ORDER BY` is used to sort the output.
4040

4141
.Query
42+
// tag::clauses_order_by[]
4243
[source, cypher]
4344
----
4445
MATCH (n)
4546
RETURN n.name, n.age
4647
ORDER BY n.name
4748
----
49+
// end::clauses_order_by[]
4850

4951
The nodes are returned, sorted by their name.
5052

@@ -66,12 +68,14 @@ You can order by multiple properties by stating each variable in the `ORDER BY`
6668
Cypher will sort the result by the first variable listed, and for equals values, go to the next property in the `ORDER BY` clause, and so on.
6769

6870
.Query
71+
// tag::clauses_order_by_multiple[]
6972
[source, cypher]
7073
----
7174
MATCH (n)
7275
RETURN n.name, n.age
7376
ORDER BY n.age, n.name
7477
----
78+
// end::clauses_order_by_multiple[]
7579

7680
This returns the nodes, sorted first by their age, and then by their name.
7781

@@ -245,12 +249,14 @@ Read more about this capability in xref::indexes/search-performance-indexes/usin
245249

246250

247251
.Standalone use of `ORDER BY`
252+
// tag::clauses_order_by_standalone[]
248253
[source, cypher]
249254
----
250255
MATCH (n)
251256
ORDER BY n.name
252257
RETURN collect(n.name) AS names
253258
----
259+
// end::clauses_order_by_standalone[]
254260

255261
.Result
256262
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -263,6 +269,7 @@ RETURN collect(n.name) AS names
263269
The following query orders all nodes by `name` descending, skips the first row and limits the results to one row.
264270

265271
.`ORDER BY` used in conjunction with `SKIP` and `LIMIT`
272+
// tag::clauses_order_by_descending[]
266273
[source, cypher]
267274
----
268275
MATCH (n)
@@ -271,6 +278,7 @@ SKIP 1
271278
LIMIT 1
272279
RETURN n.name AS name
273280
----
281+
// end::clauses_order_by_descending[]
274282

275283
.Result
276284
[role="queryresult",options="header,footer",cols="1*<m"]

0 commit comments

Comments
 (0)