Skip to content

Commit dc20574

Browse files
Include statements for functions section (#1004)
Various queries in the Cypher Quick Reference are formatted differently. I wasn't sure which way is preferable, so i did not change anything, but it's something to keep in mind during a review --------- Co-authored-by: Jens Pryce-Åklundh <[email protected]>
1 parent d61392b commit dc20574

File tree

13 files changed

+272
-4
lines changed

13 files changed

+272
-4
lines changed

modules/ROOT/pages/functions/aggregating.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ CREATE
6363
======
6464
6565
.Query
66+
// tag::functions_aggregating_avg[]
6667
[source, cypher]
6768
----
6869
MATCH (p:Person)
6970
RETURN avg(p.age)
7071
----
72+
// end::functions_aggregating_avg[]
7173
7274
The average of all the values in the property `age` is returned:
7375
@@ -87,11 +89,13 @@ The average of all the values in the property `age` is returned:
8789
======
8890
8991
.Query
92+
// tag::functions_aggregating_duration_avg[]
9093
[source, cypher]
9194
----
9295
UNWIND [duration('P2DT3H'), duration('PT1H45S')] AS dur
9396
RETURN avg(dur)
9497
----
98+
// end::functions_aggregating_duration_avg[]
9599
96100
The average of the two supplied `DURATION` values is returned:
97101
@@ -133,11 +137,13 @@ The average of the two supplied `DURATION` values is returned:
133137
======
134138
135139
.Query
140+
// tag::functions_aggregating_collect[]
136141
[source, cypher]
137142
----
138143
MATCH (p:Person)
139144
RETURN collect(p.age)
140145
----
146+
// end::functions_aggregating_collect[]
141147
142148
All the values are collected and returned in a single list:
143149
@@ -189,11 +195,13 @@ The function `count(*)` can be used to return the number of nodes; for example,
189195
======
190196
191197
.Query
198+
// tag::functions_aggregating_count[]
192199
[source, cypher]
193200
----
194201
MATCH (p:Person {name: 'Keanu Reeves'})-->(x)
195202
RETURN labels(p), p.age, count(*)
196203
----
204+
// end::functions_aggregating_count[]
197205
198206
The labels and `age` property of the start node `Keanu Reeves` and the number of nodes related to it are returned:
199207
@@ -248,11 +256,13 @@ Instead of simply returning the number of rows with `count(*)`, the function `co
248256
======
249257
250258
.Query
259+
// tag::functions_aggregating_count_as_expression[]
251260
[source, cypher]
252261
----
253262
MATCH (p:Person)
254263
RETURN count(p.age)
255264
----
265+
// end::functions_aggregating_count_as_expression[]
256266
257267
The number of nodes with the label `Person` and a property `age` is returned:
258268
(To calculate the sum, use `sum(n.age)`)
@@ -389,11 +399,13 @@ The highest of all the lists in the set -- in this case, the list `[1, 2]` -- is
389399
======
390400
391401
.Query
402+
// tag::functions_aggregating_max[]
392403
[source, cypher]
393404
----
394405
MATCH (p:Person)
395406
RETURN max(p.age)
396407
----
408+
// end::functions_aggregating_max[]
397409
398410
The highest of all the values in the property `age` is returned:
399411
@@ -486,11 +498,13 @@ The lowest of all the values in the set -- in this case, the list `['a', 'c', 23
486498
======
487499
488500
.Query
501+
// tag::functions_aggregating_min[]
489502
[source, cypher]
490503
----
491504
MATCH (p:Person)
492505
RETURN min(p.age)
493506
----
507+
// end::functions_aggregating_min[]
494508
495509
The lowest of all the values in the property `age` is returned:
496510
@@ -532,11 +546,13 @@ The lowest of all the values in the property `age` is returned:
532546
======
533547
534548
.Query
549+
// tag::functions_aggregating_percentile_cont[]
535550
[source, cypher]
536551
----
537552
MATCH (p:Person)
538553
RETURN percentileCont(p.age, 0.4)
539554
----
555+
// end::functions_aggregating_percentile_cont[]
540556
541557
The 40th percentile of the values in the property `age` is returned, calculated with a weighted average:
542558
@@ -579,11 +595,13 @@ The 40th percentile of the values in the property `age` is returned, calculated
579595
======
580596
581597
.Query
598+
// tag::functions_aggregating_percentile_disc[]
582599
[source, cypher]
583600
----
584601
MATCH (p:Person)
585602
RETURN percentileDisc(p.age, 0.5)
586603
----
604+
// end::functions_aggregating_percentile_disc[]
587605
588606
The 50th percentile of the values in the property `age` is returned:
589607
@@ -625,12 +643,14 @@ The 50th percentile of the values in the property `age` is returned:
625643
======
626644
627645
.Query
646+
// tag::functions_aggregating_stdev[]
628647
[source, cypher]
629648
----
630649
MATCH (p:Person)
631650
WHERE p.name IN ['Keanu Reeves', 'Liam Neeson', 'Carrie Anne Moss']
632651
RETURN stDev(p.age)
633652
----
653+
// end::functions_aggregating_stdev[]
634654
635655
The standard deviation of the values in the property `age` is returned:
636656
@@ -672,12 +692,14 @@ The standard deviation of the values in the property `age` is returned:
672692
======
673693
674694
.Query
695+
// tag::functions_aggregating_stdevp[]
675696
[source, cypher]
676697
----
677698
MATCH (p:Person)
678699
WHERE p.name IN ['Keanu Reeves', 'Liam Neeson', 'Carrie Anne Moss']
679700
RETURN stDevP(p.age)
680701
----
702+
// end::functions_aggregating_stdevp[]
681703
682704
The population standard deviation of the values in the property `age` is returned:
683705
@@ -719,11 +741,13 @@ The population standard deviation of the values in the property `age` is returne
719741
======
720742
721743
.Query
744+
// tag::functions_aggregating_sum[]
722745
[source, cypher]
723746
----
724747
MATCH (p:Person)
725748
RETURN sum(p.age)
726749
----
750+
// end::functions_aggregating_sum[]
727751
728752
The sum of all the values in the property `age` is returned:
729753
@@ -744,11 +768,13 @@ The sum of all the values in the property `age` is returned:
744768
======
745769
746770
.Query
771+
// tag::functions_aggregating_sum_duration[]
747772
[source, cypher]
748773
----
749774
UNWIND [duration('P2DT3H'), duration('PT1H45S')] AS dur
750775
RETURN sum(dur)
751776
----
777+
// end::functions_aggregating_sum_duration[]
752778
753779
The sum of the two supplied durations is returned:
754780

modules/ROOT/pages/functions/database.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
======
2727
2828
.Query
29+
// tag::functions_database_name_from_element_id[]
2930
[source, cypher, indent=0]
3031
----
3132
WITH "2:efc7577d-022a-107c-a736-dbcdfc189c03:0" AS eid
3233
RETURN db.nameFromElementId(eid) AS name
3334
----
35+
// end::functions_database_name_from_element_id[]
3436
3537
Returns the name of the database which the element id belongs to.
3638

modules/ROOT/pages/functions/graph.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ CREATE ALIAS composite.third FOR DATABASE dbc;
3434
----
3535
3636
.Query
37+
// tag::functions_graph_names[]
3738
[source, cypher, indent=0]
3839
----
3940
RETURN graph.names() AS name
4041
----
42+
// end::functions_graph_names[]
4143
4244
The names of all graphs on the current composite database are returned.
4345
@@ -91,11 +93,13 @@ CREATE ALIAS composite.third FOR DATABASE dbc
9193
----
9294
9395
.Query
96+
// tag::functions_graph_properties_by_name[]
9497
[source, cypher, indent=0]
9598
----
9699
UNWIND graph.names() AS name
97100
RETURN name, graph.propertiesByName(name) AS props
98101
----
102+
// end::functions_graph_properties_by_name[]
99103
100104
Properties for all graphs on the current composite database are returned.
101105
@@ -150,7 +154,8 @@ For more information, see xref:subqueries/call-subquery.adoc#import-variables[CA
150154
======
151155
152156
.Query
153-
[source, cypher, indent=0]
157+
// tag::functions_graph_by_name[]
158+
[source, cypher, role=noplay]
154159
----
155160
UNWIND graph.names() AS graphName
156161
CALL () {
@@ -160,6 +165,7 @@ CALL () {
160165
}
161166
RETURN n
162167
----
168+
// end::functions_graph_by_name[]
163169
164170
Returns all nodes from all graphs on the current composite database.
165171
@@ -194,10 +200,12 @@ For more information, see xref:subqueries/call-subquery.adoc#import-variables[CA
194200
In this example, it is assumed that the DBMS contains a composite database constituent, which contains the element id `4:c0a65d96-4993-4b0c-b036-e7ebd9174905:0`.
195201
196202
.Query
203+
// tag::functions_graph_by_element_id[]
197204
[source, cypher, role=test-skip]
198205
----
199206
USE graph.byElementId("4:c0a65d96-4993-4b0c-b036-e7ebd9174905:0")
200207
MATCH (n) RETURN n
201208
----
209+
// end::functions_graph_by_element_id[]
202210
203211
======

0 commit comments

Comments
 (0)