Skip to content

Commit e42cf1a

Browse files
committed
tags for READ query section (#1133)
1 parent ddcf016 commit e42cf1a

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

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"]
@@ -195,11 +199,13 @@ RETURN movie.title AS movieTitle
195199
It is possible to introduce a variable to a pattern, either for filtering on relationship properties or to return a relationship.
196200

197201
.Find the types of an aliased relationship
202+
// tag::clauses_match_relationship_types[]
198203
[source, cypher]
199204
----
200205
MATCH (:Person {name: 'Oliver Stone'})-[r]->()
201206
RETURN type(r) AS relType
202207
----
208+
// end::clauses_match_relationship_types[]
203209

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

246252
.Relationship pattern filtering on the `ACTED_IN` relationship type
253+
// tag::clauses_match_relationship[]
247254
[source, cypher]
248255
----
249256
MATCH (:Movie {title: 'Wall Street'})<-[:ACTED_IN]-(actor:Person)
250257
RETURN actor.name AS actor
251258
----
259+
// end::clauses_match_relationship[]
252260

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

402410
.Find all paths matching a pattern
411+
// tag::clauses_match_path[]
403412
[source, cypher]
404413
----
405414
MATCH path = ()-[:ACTED_IN]->(movie:Movie)
406415
RETURN path
407416
----
417+
// end::clauses_match_path[]
408418

409419
.Result
410420
[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/return.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ CREATE
3232
To return a node, list it in the `RETURN` clause:
3333

3434
.Query
35+
// tag::clauses_return_node[]
3536
[source, cypher]
3637
----
3738
MATCH (p:Person {name: 'Keanu Reeves'})
3839
RETURN p
3940
----
41+
// end::clauses_return_node[]
4042

4143
.Result
4244
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -53,11 +55,13 @@ d|Rows: 1
5355
To return a relationship type, list it in the `RETURN` clause:
5456

5557
.Query
58+
// tag::clauses_return_relationship_type[]
5659
[source, cypher]
5760
----
5861
MATCH (p:Person {name: 'Keanu Reeves'})-[r:ACTED_IN]->(m)
5962
RETURN type(r)
6063
----
64+
// end::clauses_return_relationship_type[]
6165

6266
.Result
6367
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -74,11 +78,13 @@ d|Rows: 1
7478
To return a specific property, use the dot separator:
7579

7680
.Query
81+
// tag::clauses_return_property[]
7782
[source, cypher]
7883
----
7984
MATCH (p:Person {name: 'Keanu Reeves'})
8085
RETURN p.bornIn
8186
----
87+
// end::clauses_return_property[]
8288

8389
.Result
8490
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -101,11 +107,13 @@ This will improve performance.
101107
To return all nodes, relationships and paths found in a query, use the `*` symbol:
102108

103109
.Query
110+
// tag::clauses_return_all_elements[]
104111
[source, cypher]
105112
----
106113
MATCH p = (keanu:Person {name: 'Keanu Reeves'})-[r]->(m)
107114
RETURN *
108115
----
116+
// end::clauses_return_all_elements[]
109117

110118
This returns the two nodes, and the two possible paths between them.
111119

@@ -149,11 +157,13 @@ d|Rows: 1
149157
Names of returned columns can be renamed using the `AS` operator:
150158

151159
.Query
160+
// tag::clauses_return_with_column_alias[]
152161
[source, cypher]
153162
----
154163
MATCH (p:Person {name: 'Keanu Reeves'})
155164
RETURN p.nationality AS citizenship
156165
----
166+
// end::clauses_return_with_column_alias[]
157167

158168
Returns the `nationality` property of `'Keanu Reeves'`, but the column is renamed to `citizenship`.
159169

@@ -220,11 +230,13 @@ Returns a predicate, a literal and function call with a pattern expression param
220230
`DISTINCT` retrieves only unique rows for the columns that have been selected for output.
221231

222232
.Query
233+
// tag::clauses_return_distinct[]
223234
[source, cypher]
224235
----
225236
MATCH (p:Person {name: 'Keanu Reeves'})-->(m)
226237
RETURN DISTINCT m
227238
----
239+
// end::clauses_return_distinct[]
228240

229241
The `Movie` node `'Man of Tai Chi'` is returned by the query, but only once (without the `DISTINCT` operator it would have been returned twice because there are two relationships going to it from `'Keanu Reeves'`):
230242

modules/ROOT/pages/clauses/union.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ CREATE (johnny:Actor {name: 'Johnny Depp'}),
4545
Combining the results from two queries is done using `UNION ALL`.
4646

4747
.Query
48+
// tag::clauses_union_all[]
4849
[source, cypher]
4950
----
5051
MATCH (n:Actor)
@@ -53,6 +54,7 @@ UNION ALL
5354
MATCH (n:Movie)
5455
RETURN n.title AS name
5556
----
57+
// end::clauses_union_all[]
5658

5759
The combined result is returned, including duplicates.
5860

@@ -74,6 +76,7 @@ The combined result is returned, including duplicates.
7476
By not including `ALL` in the `UNION`, duplicates are removed from the combined result set.
7577

7678
.Query
79+
// tag::clauses_union[]
7780
[source, cypher]
7881
----
7982
MATCH (n:Actor)
@@ -82,6 +85,7 @@ UNION
8285
MATCH (n:Movie)
8386
RETURN n.title AS name
8487
----
88+
// end::clauses_union[]
8589

8690
The combined result is returned, without duplicates.
8791

modules/ROOT/pages/clauses/where.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ CREATE
4646
`WHERE` can appear inside a node pattern in a `MATCH` clause or a pattern comprehension:
4747

4848
.Query
49+
// tag::clauses_where_in_match_clause[]
4950
[source, cypher]
5051
----
5152
WITH 30 AS minAge
5253
MATCH (a:Person WHERE a.name = 'Andy')-[:KNOWS]->(b:Person WHERE b.age > minAge)
5354
RETURN b.name
5455
----
56+
// end::clauses_where_in_match_clause[]
5557

5658
.Result
5759
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -66,11 +68,13 @@ When used this way, predicates in `WHERE` can reference the node variable that t
6668
The same rule applies to pattern comprehensions:
6769

6870
.Query
71+
// tag::clauses_where_pattern_comprehension[]
6972
[source, cypher]
7073
----
7174
MATCH (a:Person {name: 'Andy'})
7275
RETURN [(a)-->(b WHERE b:Person) | b.name] AS friends
7376
----
77+
// end::clauses_where_pattern_comprehension[]
7478

7579
.Result
7680
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -87,6 +91,7 @@ The following boolean operators can be used with the `WHERE` clause: `AND`, `OR`
8791
For more information on how operators work with `null`, see the chapter on xref::values-and-types/working-with-null.adoc[Working with null].
8892

8993
.Query
94+
// tag::clauses_where_boolean_operations[]
9095
[source, cypher]
9196
----
9297
MATCH (n:Person)
@@ -96,6 +101,7 @@ RETURN
96101
n.age AS age
97102
ORDER BY name
98103
----
104+
// end::clauses_where_boolean_operations[]
99105

100106
.Result
101107
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -114,12 +120,14 @@ ORDER BY name
114120
To filter nodes by label, write a label predicate after the `WHERE` keyword using `WHERE n:foo`:
115121

116122
.Query
123+
// tag::clauses_where_node_label[]
117124
[source, cypher]
118125
----
119126
MATCH (n)
120127
WHERE n:Swedish
121128
RETURN n.name, n.age
122129
----
130+
// end::clauses_where_node_label[]
123131

124132
The `name` and `age` values for `Andy` are returned:
125133

@@ -138,12 +146,14 @@ The `name` and `age` values for `Andy` are returned:
138146
To filter on a node property, write your clause after the `WHERE` keyword:
139147

140148
.Query
149+
// tag::clauses_where_node_property[]
141150
[source, cypher]
142151
----
143152
MATCH (n:Person)
144153
WHERE n.age < 30
145154
RETURN n.name, n.age
146155
----
156+
// end::clauses_where_node_property[]
147157

148158
The `name` and `age` values for `Timothy` are returned because he is less than 30 years of age:
149159

@@ -162,12 +172,14 @@ The `name` and `age` values for `Timothy` are returned because he is less than 3
162172
To filter on a relationship property, write your clause after the `WHERE` keyword:
163173

164174
.Query
175+
// tag::clauses_where_relationship_property[]
165176
[source, cypher]
166177
----
167178
MATCH (n:Person)-[k:KNOWS]->(f)
168179
WHERE k.since < 2000
169180
RETURN f.name, f.age, f.email
170181
----
182+
// end::clauses_where_relationship_property[]
171183

172184
The `name`, `age` and `email` values for `Peter` are returned because `Andy` has known him since before 2000:
173185

@@ -218,12 +230,14 @@ The `name` and `age` values for `Timothy` are returned because he is less than 3
218230
Use the `IS NOT NULL` predicate to only include nodes or relationships in which a property exists:
219231

220232
.Query
233+
// tag::clauses_where_property_existence[]
221234
[source, cypher]
222235
----
223236
MATCH (n:Person)
224237
WHERE n.belt IS NOT NULL
225238
RETURN n.name, n.belt
226239
----
240+
// end::clauses_where_property_existence[]
227241

228242
The `name` and `belt` values for `Andy` are returned because he is the only one with a `belt` property:
229243

@@ -242,13 +256,15 @@ The `name` and `belt` values for `Andy` are returned because he is the only one
242256
As `WHERE` is not considered a clause in its own right, its scope is not limited by a `WITH` directly before it.
243257

244258
.Query
259+
// tag::clauses_where_with[]
245260
[source, cypher]
246261
----
247262
MATCH (n:Person)
248263
WITH n.name as name
249264
WHERE n.age = 25
250265
RETURN name
251266
----
267+
// end::clauses_where_with[]
252268

253269
.Result
254270
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -538,6 +554,7 @@ The following sections will demonstrate how to use path pattern expressions in a
538554
=== Filter on patterns
539555

540556
.Query
557+
// tag::clauses_where_patterns[]
541558
[source, cypher]
542559
----
543560
MATCH
@@ -546,6 +563,7 @@ MATCH
546563
WHERE (other)-->(timothy)
547564
RETURN other.name, other.age
548565
----
566+
// end::clauses_where_patterns[]
549567

550568
The `name` and `age` values for nodes that have an outgoing relationship to `Timothy` are returned:
551569

@@ -618,12 +636,14 @@ To check if an element exists in a list, use the `IN` operator.
618636
The below query checks whether a property exists in a literal list:
619637

620638
.Query
639+
// tag::clauses_where_lists[]
621640
[source, cypher]
622641
----
623642
MATCH (a:Person)
624643
WHERE a.name IN ['Peter', 'Timothy']
625644
RETURN a.name, a.age
626645
----
646+
// end::clauses_where_lists[]
627647

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

modules/ROOT/pages/clauses/with.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ CREATE
5656
You can introduce new variables for the result of evaluating expressions.
5757

5858
.Query
59+
// tag::clauses_with_variables[]
5960
[source, cypher, indent=0]
6061
----
6162
MATCH (george {name: 'George'})<--(otherPerson)
6263
WITH otherPerson, toUpper(otherPerson.name) AS upperCaseName
6364
WHERE upperCaseName STARTS WITH 'C'
6465
RETURN otherPerson.name
6566
----
67+
// end::clauses_with_variables[]
6668

6769
This query returns the name of persons connected to *'George'* whose name starts with a `C`, regardless of capitalization.
6870

@@ -81,12 +83,14 @@ This query returns the name of persons connected to *'George'* whose name starts
8183
You can use the wildcard `*` to carry over all variables that are in scope, in addition to introducing new variables.
8284

8385
.Query
86+
// tag::clauses_with_wildcard[]
8487
[source, cypher, indent=0]
8588
----
8689
MATCH (person)-[r]->(otherPerson)
8790
WITH *, type(r) AS connectionType
8891
RETURN person.name, otherPerson.name, connectionType
8992
----
93+
// end::clauses_with_wildcard[]
9094

9195
This query returns the names of all related persons and the type of relationship between them.
9296

0 commit comments

Comments
 (0)