Skip to content

Commit 5eeb4ce

Browse files
Tags for Cypher 25 cheat sheet (#1260)
1 parent a72c488 commit 5eeb4ce

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

modules/ROOT/pages/clauses/filter.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ RETURN n.name AS name
5353
|===
5454

5555
.Filter on a node property
56+
// tag::clauses_filter_node_property[]
5657
[source, cypher]
5758
----
5859
MATCH (n:Person)
5960
FILTER n.age < 35
6061
RETURN n.name AS name, n.age AS age
6162
----
63+
// end::clauses_filter_node_property[]
6264

6365
.Result
6466
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -105,12 +107,15 @@ To filter on a property using a dynamically computed name, use square brackets `
105107
----
106108

107109
.Filter on a dynamically computed node property
110+
// tag::clauses_filter_dynamic[]
108111
[source, cypher]
109112
----
110113
MATCH (n:Person)
111114
FILTER n[$propname] > 40
112115
RETURN n.name AS name, n.age AS age
113116
----
117+
// end::clauses_filter_dynamic[]
118+
114119

115120
.Result
116121
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -275,12 +280,15 @@ MERGE (c:Company {id: row.Id})
275280
----
276281
277282
.`LOAD CSV` using `FILTER`
283+
// tag::clauses_filter_load_csv[]
278284
[source, cypher]
279285
----
280286
LOAD CSV WITH HEADERS FROM 'file:///companies.csv' AS row
281287
FILTER row.Id IS NOT NULL
282288
MERGE (c:Company {id: row.Id})
283289
----
290+
// end::clauses_filter_load_csv[]
291+
284292
285293
=====
286294

modules/ROOT/pages/clauses/let.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,14 @@ RETURN fullName
9595
|===
9696

9797
.Using `LET` to bind several variables
98+
// tag::clauses_let_bind_variables[]
9899
[source, cypher]
99100
----
100101
MATCH (s:Supplier)-[:SUPPLIES]->(p:Product)
101102
LET supplier = s.name, product = p.name
102103
RETURN supplier, product
103104
----
105+
// end::clauses_let_bind_variables[]
104106

105107
.Result
106108
[role="queryresult",options="header,footer", cols="2*<m"]
@@ -191,6 +193,7 @@ Specifically, the variable `isExpensive` is created in the first `LET` clause an
191193
Note also that the variable `p`, bound in the `MATCH` clause, is available in the final `RETURN` clause despite not being referenced in any of `LET` clauses.
192194
193195
.`LET` referencing variables assigned in previous a `LET`
196+
// tag::clauses_let_chain_expressions[]
194197
[source, cypher]
195198
----
196199
MATCH (p:Product)
@@ -203,6 +206,7 @@ END
203206
RETURN p.name AS product, p.price AS price, isAffordable, discountCategory
204207
ORDER BY price
205208
----
209+
// end::clauses_let_chain_expressions[]
206210
207211
.Result
208212
[role="queryresult",options="header,footer", cols="4*<m"]

modules/ROOT/pages/functions/mathematical-trigonometric.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,12 @@ The cosine of `0.5` is returned.
259259
======
260260
261261
.Query
262-
// tag::functions_mathematical_trigonometric_cos[]
262+
// tag::functions_mathematical_trigonometric_cosh[]
263263
[source, cypher, indent=0]
264264
----
265265
RETURN cosh(0.7)
266266
----
267-
// end::functions_mathematical_trigonometric_cos[]
267+
// end::functions_mathematical_trigonometric_cosh[]
268268
269269
The hyperbolic cosine of `0.7` is returned.
270270
@@ -353,12 +353,12 @@ The cotangent of `0.5` is returned.
353353
======
354354
355355
.Query
356-
// tag::functions_mathematical_trigonometric_cot[]
356+
// tag::functions_mathematical_trigonometric_coth[]
357357
[source, cypher, indent=0]
358358
----
359359
RETURN coth(0.7)
360360
----
361-
// end::functions_mathematical_trigonometric_cot[]
361+
// end::functions_mathematical_trigonometric_coth[]
362362
363363
The hyperbolic cotangent of `0.7` is returned.
364364
@@ -654,12 +654,12 @@ The sine of `0.5` is returned.
654654
======
655655
656656
.Query
657-
// tag::functions_mathematical_trigonometric_sin[]
657+
// tag::functions_mathematical_trigonometric_sinh[]
658658
[source, cypher, indent=0]
659659
----
660660
RETURN sinh(0.7)
661661
----
662-
// end::functions_mathematical_trigonometric_sin[]
662+
// end::functions_mathematical_trigonometric_sinh[]
663663
664664
The hyperbolic sine of `0.7` is returned.
665665
@@ -748,12 +748,12 @@ The tangent of `0.5` is returned.
748748
======
749749
750750
.Query
751-
// tag::functions_mathematical_trigonometric_tan[]
751+
// tag::functions_mathematical_trigonometric_tanh[]
752752
[source, cypher, indent=0]
753753
----
754754
RETURN tanh(0.7)
755755
----
756-
// end::functions_mathematical_trigonometric_tan[]
756+
// end::functions_mathematical_trigonometric_tanh[]
757757
758758
The hyperbolic tangent of `0.7` is returned.
759759

modules/ROOT/pages/functions/temporal/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,13 +1365,13 @@ RETURN dateTimeFromEpoch
13651365
======
13661366
13671367
.Query
1368-
// tag::functions_temporal_datetime_fromepochmillis
1368+
// tag::functions_temporal_datetime_fromepochmillis[]
13691369
[source, cypher]
13701370
----
13711371
WITH datetime.fromEpochMillis(1724198400000) AS dateTimeFromMillis
13721372
RETURN dateTimeFromMillis
13731373
----
1374-
// end::functions_temporal_datetime_fromepochmillis
1374+
// end::functions_temporal_datetime_fromepochmillis[]
13751375
13761376
.Result
13771377
[role="queryresult",options="header,footer",cols="1*<m"]

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ To combine `UNION` (or `UNION DISTINCT`) and `UNION ALL` in the same query, encl
172172
This allows the enclosed query to act as an argument that can be combined with an outer `UNION` operation of any type.
173173

174174
.Combine `UNION` and `UNION ALL`
175+
// tag::combined_queries_top_level_braces[]
175176
[source, cypher]
176177
----
177178
{
@@ -185,6 +186,7 @@ UNION ALL
185186
MATCH (n:Movie)
186187
RETURN n.title AS name
187188
----
189+
// end::combined_queries_top_level_braces[]
188190

189191
The combined result is returned.
190192

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ If no `WHEN` branches evaluates to `true` and no `ELSE` branch is present, no br
5252
The following examples demonstrates this logic:
5353

5454
.Conditional logic
55+
// tag::conditional_queries_logic[]
5556
[source, cypher]
5657
----
5758
WHEN false THEN RETURN 1 AS x
5859
WHEN true THEN RETURN 2 AS x
5960
WHEN true THEN RETURN 3 AS x
6061
ELSE RETURN 3 AS x
6162
----
63+
// end::conditional_queries_logic[]
6264

6365
Since the second `WHEN` branch is `true`, it will execute, while the preceding branch (which is `false`) and the succeeding `WHEN` branch (which is `true`) as well as the `ELSE` branch will be skipped.
6466

@@ -72,6 +74,7 @@ Since the second `WHEN` branch is `true`, it will execute, while the preceding b
7274
|===
7375

7476
.Conditionally executing queries in standalone `WHEN` branches
77+
// tag::conditional_queries_standalone_when[]
7578
[source, cypher]
7679
----
7780
WHEN true THEN {
@@ -83,6 +86,7 @@ ELSE {
8386
RETURN n.name AS name
8487
}
8588
----
89+
// end::conditional_queries_standalone_when[]
8690

8791
[NOTE]
8892
The enclosing `{}` in the above example and the below examples are not required (unless explicitly stated), but they clarify the different conditional branches of the query.
@@ -169,6 +173,7 @@ Instead, if `WHEN` constructs are part of a larger query, they must either be pl
169173
In this example, `WHEN` is used to execute a xref:subqueries/call-subquery.adoc[`CALL` subquery] for each row that the condition (`manager IS NULL`) evaluates to `true`.
170174
171175
.Conditional `CALL` subquery
176+
// tag::conditional_queries_call[]
172177
[source, cypher]
173178
----
174179
MATCH (n:Person)
@@ -183,6 +188,7 @@ CALL (*) {
183188
RETURN newManager.name AS newManager,
184189
collect(employee) AS employees
185190
----
191+
// end::conditional_queries_call[]
186192
187193
Because only `Daniel` and `Eskil` had no outgoing `WORKS_FOR` relationships, they have now been connected as employees of the new `Peter` node.
188194
@@ -274,6 +280,7 @@ In this example, `WHEN` is used inside an `EXISTS` subquery to conditionally exe
274280
Unlike `CALL` subqueries, variables returned in an `EXISTS` subquery are not available to the outer scope (the same is true for `COUNT` and `COLLECT` subqueries).
275281
276282
.`WHEN` inside an `EXISTS` subquery
283+
// tag::conditional_queries_exists[]
277284
[source, cypher]
278285
----
279286
MATCH (n:Person)
@@ -289,6 +296,7 @@ WHERE EXISTS {
289296
RETURN n.name AS name,
290297
n.age AS age
291298
----
299+
// end::conditional_queries_exists[]
292300
293301
`Alice` and `Charlie` are both older than `40,` so they are returned by the `WHEN` branch, while `Bob` is returned by the `ELSE` branch.
294302
Note that some `Person` nodes in the graph are not matched in either branch of the conditional subquery, and are therefore not returned.
@@ -340,6 +348,7 @@ UNION [DISTINCT|ALL]
340348
----
341349

342350
.Combining conditional branches with `UNION` using `{}`
351+
// tag::conditional_queries_union[]
343352
[source, cypher]
344353
----
345354
{
@@ -354,6 +363,7 @@ UNION
354363
ELSE RETURN 6 AS x
355364
}
356365
----
366+
// end::conditional_queries_union[]
357367

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

0 commit comments

Comments
 (0)