Skip to content

Commit 9c57b8e

Browse files
match modes and NEXT cheat sheet tags (#1310)
Co-authored-by: Richard Sill <[email protected]>
1 parent 742fc81 commit 9c57b8e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

modules/ROOT/pages/patterns/match-modes.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,13 @@ _In the `samplePath` with a length of `6` returned by `DIFFERENT RELATIONSHIPS`,
115115
However, if the relationship count is increased to `7`, `0` paths are returned.
116116

117117
.Find paths with a length of 7 relationships
118+
// tag::patterns_match_modes_different_relationships[]
118119
[source, cypher]
119120
----
120121
MATCH p = (:Location {name: 'Kneiphof'})--{7}()
121122
RETURN count(p) AS pathCount
122123
----
124+
// end::patterns_match_modes_different_relationships[]
123125

124126
.Result
125127
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -153,13 +155,15 @@ Queries utilizing this match mode must specify the `REPEATABLE ELEMENTS` keyword
153155
The following query matches the graph for paths with a length of `7` relationships using `REPEATABLE ELEMENTS` and returns a sample path.
154156

155157
.Find a path with a length of 7 relationships using `REPEATABLE ELEMENTS`
158+
// tag::patterns_match_modes_repeatable_elements[]
156159
[source, cypher]
157160
----
158161
MATCH REPEATABLE ELEMENTS p = (:Location {name: 'Kneiphof'})-[:BRIDGE]-{7}()
159162
WITH collect(p)[0] AS samplePath
160163
RETURN [n IN nodes(samplePath) | n.name] AS samplePathLocations,
161164
[r IN relationships(samplePath) | r.id] AS samplePathBridges
162165
----
166+
// end::patterns_match_modes_repeatable_elements[]
163167

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

modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ RETURN customer.firstName AS chocolateCustomer
109109

110110

111111
.Passing multiple variables to another query via `NEXT`
112+
// tag::sequential_queries_basic_example[]
112113
[source, cypher]
113114
----
114115
MATCH (c:Customer)-[:BUYS]->(p:Product {name: 'Chocolate'})
@@ -119,6 +120,7 @@ NEXT
119120
RETURN customer.firstName AS chocolateCustomer,
120121
product.price * (1 - customer.discount) AS chocolatePrice
121122
----
123+
// end::sequential_queries_basic_example[]
122124

123125
.Result
124126
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -162,6 +164,8 @@ RETURN p.name as product, customers
162164
======
163165
[.include-with-NEXT]
164166
======
167+
168+
// tag::sequential_queries_call[]
165169
[source, cypher]
166170
----
167171
MATCH (p:Product)
@@ -176,6 +180,7 @@ NEXT
176180
177181
RETURN p.name as product, customers
178182
----
183+
// end::sequential_queries_call[]
179184
======
180185
====
181186

@@ -204,6 +209,7 @@ It also avoids the parentheses and indentation of the `CALL` subquery.
204209
== Interactions with conditional queries
205210

206211
.Conditional queries in `NEXT`
212+
// tag::sequential_queries_chaining_conditional_queries[]
207213
[source, cypher]
208214
----
209215
MATCH (c:Customer)-[:BUYS]->(:Product)<-[:SUPPLIES]-(s:Supplier)
@@ -227,6 +233,7 @@ WHEN size(personalities) > 1 THEN
227233
ELSE
228234
RETURN customer, personalities[0] AS personality
229235
----
236+
// end::sequential_queries_chaining_conditional_queries[]
230237

231238
.Result
232239
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -255,6 +262,7 @@ Finally, the fourth segment is another conditional query which subsumes multiple
255262
If a conditional query has a `NEXT` in any of its `THEN` or `ELSE` blocks, it is necessary to wrap the part after `THEN` or `ELSE` with `{}`.
256263

257264
.`NEXT` inside a conditional query
265+
// tag::sequential_queries_in_conditional_queries[]
258266
[source, cypher]
259267
----
260268
MATCH (c:Customer)-[:BUYS]->(p:Product)
@@ -273,6 +281,7 @@ ELSE {
273281
RETURN customer.firstName AS customer, "club below 1000" AS customerType, finalSum AS sum
274282
}
275283
----
284+
// end::sequential_queries_in_conditional_queries[]
276285

277286
.Result
278287
[role="queryresult",options="header,footer",cols="3*<m"]

0 commit comments

Comments
 (0)