Skip to content

Commit 0d22fcc

Browse files
Clean up some function pages (#1039)
1 parent a71b9d4 commit 0d22fcc

File tree

9 files changed

+88
-397
lines changed

9 files changed

+88
-397
lines changed

modules/ROOT/images/graph_list_functions.svg

Lines changed: 1 addition & 91 deletions
Loading

modules/ROOT/images/graph_numeric_functions.svg

Lines changed: 1 addition & 99 deletions
Loading

modules/ROOT/images/graph_scalar_functions.svg

Lines changed: 1 addition & 91 deletions
Loading
Lines changed: 1 addition & 40 deletions
Loading

modules/ROOT/pages/functions/aggregating.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To learn more about how Cypher handles aggregations performed on zero rows, refe
1717

1818
The following graph is used for the examples below:
1919

20-
image::graph_aggregating_functions.svg[]
20+
image::graph_aggregating_functions.svg[role="middle", width="700"]
2121

2222
To recreate the graph, run the following query against an empty Neo4j database:
2323

modules/ROOT/pages/functions/list.adoc

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ List functions return lists of different data entities.
88

99
Further details and examples of lists may be found in xref::values-and-types/lists.adoc[Lists] and xref::syntax/operators.adoc#query-operators-list[List operators].
1010

11+
[[example-graph]]
1112
== Example graph
1213

1314
The following graph is used for the examples below:
1415

15-
image:graph_list_functions.svg[]
16+
image::graph_list_functions.svg[role="middle", width="700"]
1617

17-
To recreate the graph, run the following query in an empty Neo4j database:
18+
To recreate the graph, run the following query against an empty Neo4j database:
1819

1920
[source, cypher, role=test-setup]
2021
----
2122
CREATE
22-
(alice:Person:Developer {name:'Alice', age: 38, eyes: 'brown'}),
23-
(bob {name: 'Bob', age: 25, eyes: 'blue'}),
24-
(charlie {name: 'Charlie', age: 53, eyes: 'green'}),
25-
(daniel {name: 'Daniel', age: 54, eyes: 'brown'}),
26-
(eskil {name: 'Eskil', age: 41, eyes: 'blue', array: ['one', 'two', 'three']}),
23+
(alice:Developer {name:'Alice', age: 38, eyes: 'Brown'}),
24+
(bob:Administrator {name: 'Bob', age: 25, eyes: 'Blue'}),
25+
(charlie:Administrator {name: 'Charlie', age: 53, eyes: 'Green'}),
26+
(daniel:Adminstrator {name: 'Daniel', age: 54, eyes: 'Brown'}),
27+
(eskil:Designer {name: 'Eskil', age: 41, eyes: 'blue', likedColors: ['Pink', 'Yellow', 'Black']}),
2728
(alice)-[:KNOWS]->(bob),
2829
(alice)-[:KNOWS]->(charlie),
2930
(bob)-[:KNOWS]->(daniel),
@@ -68,7 +69,7 @@ A `LIST<STRING>` containing the names of all the properties on the node bound to
6869
|===
6970
7071
| keys(a)
71-
| ["eyes","name","age"]
72+
| ["eyes", "name", "age"]
7273
1+d|Rows: 1
7374
7475
|===
@@ -115,7 +116,7 @@ A `LIST<STRING>` containing all the labels of the node bound to `a` is returned.
115116
|===
116117
117118
| labels(a)
118-
| ["Person","Developer"]
119+
| ["Developer"]
119120
1+d|Rows: 1
120121
121122
|===
@@ -160,8 +161,8 @@ A `LIST<NODE>` containing all the nodes in the path `p` is returned.
160161
[role="queryresult",options="header,footer",cols="1*<m"]
161162
|===
162163
163-
| +nodes(p)+
164-
| +[(:Person:Developer {name: "Alice",eyes: "brown",age: 38}), ({name: "Bob",eyes: "blue",age: 25}), ({array: ['one', 'two', 'three'],name: "Eskil",eyes: "blue",age: 41})]+
164+
| nodes(p)
165+
| [(:Developer {name: "Alice", eyes: "Brown", age: 38}), (:Administrator {name: "Bob", eyes: "Blue", age: 25}), (:Designer {name: "Eskil", likedColors: ["Pink", "Yellow", "Black"], eyes: "blue", age: 41})]
165166
1+d|Rows: 1
166167
167168
|===
@@ -367,17 +368,17 @@ RETURN reverse(ids)
367368
[source, cypher]
368369
----
369370
MATCH (a) WHERE a.name = 'Eskil'
370-
RETURN a.array, tail(a.array)
371+
RETURN a.likedColors, tail(a.likedColors)
371372
----
372373
373-
The property named `array` and a `LIST<ANY>` comprising all but the first element of the `array` property are returned.
374+
The property named `likedColors` and a `LIST<ANY>` comprising all but the first element of the `likedColors` property are returned.
374375
375376
.Result
376377
[role="queryresult",options="header,footer",cols="2*<m"]
377378
|===
378379
379-
| a.array | tail(a.array)
380-
| ["one","two","three"] | ["two","three"]
380+
| a.likedColors | tail(a.likedColors)
381+
| ["Pink", "Yellow", "Black"] | ["Yellow", "Black"]
381382
2+d|Rows: 1
382383
383384
|===

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,29 @@
77
Numeric mathematical functions operate on numeric expressions only, and will return an error if used on any other values.
88
See also xref::syntax/operators.adoc#query-operators-mathematical[Mathematical operators].
99

10+
[[example-graph]]
11+
== Example graph
12+
1013
The following graph is used for the examples below:
1114

12-
image:graph_numeric_functions.svg[]
15+
image::graph_numeric_functions.svg[role="middle", width="700"]
16+
17+
To recreate the graph, run the following query against an empty Neo4j database:
1318

14-
////
1519
[source, cypher, role=test-setup]
1620
----
1721
CREATE
18-
(alice:A {name:'Alice', age: 38, eyes: 'brown'}),
19-
(bob:B {name: 'Bob', age: 25, eyes: 'blue'}),
20-
(charlie:C {name: 'Charlie', age: 53, eyes: 'green'}),
21-
(daniel:D {name: 'Daniel', age: 54, eyes: 'brown'}),
22-
(eskil:E {name: 'Eskil', age: 41, eyes: 'blue', array: ['one', 'two', 'three']}),
22+
(alice:Developer {name:'Alice', age: 38, eyes: 'Brown'}),
23+
(bob:Administrator {name: 'Bob', age: 25, eyes: 'Blue'}),
24+
(charlie:Administrator {name: 'Charlie', age: 53, eyes: 'Green'}),
25+
(daniel:Adminstrator {name: 'Daniel', age: 54, eyes: 'Brown'}),
26+
(eskil:Designer {name: 'Eskil', age: 41, eyes: 'blue', likedColors: ['Pink', 'Yellow', 'Black']}),
2327
(alice)-[:KNOWS]->(bob),
2428
(alice)-[:KNOWS]->(charlie),
2529
(bob)-[:KNOWS]->(daniel),
2630
(charlie)-[:KNOWS]->(daniel),
2731
(bob)-[:MARRIED]->(eskil)
2832
----
29-
////
30-
3133

3234
[[functions-abs]]
3335
== abs()
@@ -55,7 +57,8 @@ CREATE
5557
.Query
5658
[source, cypher, indent=0]
5759
----
58-
MATCH (a), (e) WHERE a.name = 'Alice' AND e.name = 'Eskil' RETURN a.age, e.age, abs(a.age - e.age)
60+
MATCH (a), (e) WHERE a.name = 'Alice' AND e.name = 'Eskil'
61+
RETURN a.age, e.age, abs(a.age - e.age)
5962
----
6063
6164
The absolute value of the age difference is returned.

modules/ROOT/pages/functions/scalar.adoc

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,29 @@
66

77
Scalar functions return a single value.
88

9-
[IMPORTANT]
10-
====
11-
The `length()` and `size()` functions are quite similar, and so it is important to take note of the difference.
9+
[[example-graph]]
10+
== Example graph
1211

13-
Function `length()`:: Only works for xref::functions/scalar.adoc#functions-length[paths].
14-
Function `size()`:: Only works for the three types: xref::functions/scalar.adoc#functions-size-of-string[`STRING` values], xref::functions/scalar.adoc#functions-size[lists], xref::functions/scalar.adoc#functions-size-of-pattern-comprehension[pattern comprehension].
15-
====
12+
The following graph is used for the examples below:
1613

17-
image:graph_scalar_functions.svg[]
14+
image::graph_scalar_functions.svg[role="middle", width="700"]
15+
16+
To recreate the graph, run the following query against an empty Neo4j database:
1817

19-
////
2018
[source, cypher, role=test-setup]
2119
----
2220
CREATE
23-
(alice:Developer {name:'Alice', age: 38, eyes: 'brown'}),
24-
(bob {name: 'Bob', age: 25, eyes: 'blue'}),
25-
(charlie {name: 'Charlie', age: 53, eyes: 'green'}),
26-
(daniel {name: 'Daniel', age: 54, eyes: 'brown'}),
27-
(eskil {name: 'Eskil', age: 41, eyes: 'blue', liked_colors: ['pink', 'yellow', 'black']}),
21+
(alice:Developer {name:'Alice', age: 38, eyes: 'Brown'}),
22+
(bob:Administrator {name: 'Bob', age: 25, eyes: 'Blue'}),
23+
(charlie:Administrator {name: 'Charlie', age: 53, eyes: 'Green'}),
24+
(daniel:Adminstrator {name: 'Daniel', age: 54, eyes: 'Brown'}),
25+
(eskil:Designer {name: 'Eskil', age: 41, eyes: 'blue', likedColors: ['Pink', 'Yellow', 'Black']}),
2826
(alice)-[:KNOWS]->(bob),
2927
(alice)-[:KNOWS]->(charlie),
3028
(bob)-[:KNOWS]->(daniel),
3129
(charlie)-[:KNOWS]->(daniel),
3230
(bob)-[:MARRIED]->(eskil)
3331
----
34-
////
35-
3632

3733
[role=label--new-5.13]
3834
[[functions-char_length]]
@@ -162,7 +158,7 @@ RETURN coalesce(a.hairColor, a.eyes)
162158
|===
163159
164160
| coalesce(a.hairColor, a.eyes)
165-
| "brown"
161+
| "Brown"
166162
1+d|Rows: 1
167163
168164
|===
@@ -282,8 +278,8 @@ RETURN endNode(r)
282278
[role="queryresult",options="header,footer",cols="1*<m"]
283279
|===
284280
| endNode(r)
285-
| {name:"Bob",age:25,eyes:"blue"}
286-
| {name:"Charlie",age:53,eyes:"green"}
281+
| {name: "Bob", age: 25, eyes: "Blue"}
282+
| {name: "Charlie", age: 53, eyes: "Green"}
287283
1+d|Rows: 2
288284
|===
289285
@@ -320,7 +316,7 @@ RETURN endNode(r)
320316
----
321317
MATCH (a)
322318
WHERE a.name = 'Eskil'
323-
RETURN a.liked_colors, head(a.liked_colors)
319+
RETURN a.likedColors, head(a.likedColors)
324320
----
325321
326322
The first element in the list is returned.
@@ -329,8 +325,8 @@ The first element in the list is returned.
329325
[role="queryresult",options="header,footer",cols="2*<m"]
330326
|===
331327
332-
| a.liked_colors+ | +head(a.liked_colors)
333-
| ["pink","yellow","black"] | "pink"
328+
| a.likedColors+ | +head(a.likedColors)
329+
| ["Pink", "Yellow", "Black"] | "Pink"
334330
2+d|Rows: 1
335331
336332
|===
@@ -446,7 +442,7 @@ The node identifier for each of the nodes is returned.
446442
----
447443
MATCH (a)
448444
WHERE a.name = 'Eskil'
449-
RETURN a.liked_colors, last(a.liked_colors)
445+
RETURN a.likedColors, last(a.likedColors)
450446
----
451447
452448
The last element in the list is returned.
@@ -456,7 +452,7 @@ The last element in the list is returned.
456452
|===
457453
458454
| a.liked_colors | last(a.liked_colors)
459-
| ["pink","yellow","black"] | "black"
455+
| ["Pink", "Yellow", "Black"] | "Black"
460456
2+d|Rows: 1
461457
462458
|===
@@ -483,6 +479,8 @@ The last element in the list is returned.
483479

484480
|===
485481

482+
[NOTE]
483+
To calculate the length of a `LIST` of the number of Unicode characters in a `STRING`, see xref:functions/scalar.adoc#functions-size[`size()`]
486484

487485
.+length()+
488486
======
@@ -583,7 +581,7 @@ The `nullIf()` function can be used in conjunction with the `coalesce()` functio
583581
[source, cypher, indent=0]
584582
----
585583
MATCH (a)
586-
RETURN a.name AS name, coalesce(nullIf(a.eyes, "brown"), "hazel") AS eyeColor
584+
RETURN a.name AS name, coalesce(nullIf(a.eyes, "Brown"), "Hazel") AS eyeColor
587585
----
588586
589587
@@ -592,11 +590,11 @@ RETURN a.name AS name, coalesce(nullIf(a.eyes, "brown"), "hazel") AS eyeColor
592590
|===
593591
594592
| name | eyeColor
595-
| "Alice" | "hazel"
596-
| "Bob" | "blue"
597-
| "Charlie" | "green"
598-
| "Daniel" | "hazel"
599-
| "Eskil" | "blue"
593+
| "Alice" | "Hazel"
594+
| "Bob" | "Blue"
595+
| "Charlie" | "Green"
596+
| "Daniel" | "Hazel"
597+
| "Eskil" | "Blue"
600598
2+d|Rows: 5
601599
602600
|===
@@ -640,7 +638,7 @@ RETURN properties(p)
640638
|===
641639
642640
| properties(p)
643-
| {"city":"Berlin","name":"Stefan"}
641+
| {"city": "Berlin", "name": "Stefan"}
644642
1+d|Rows: 1
645643
|===
646644
@@ -693,6 +691,9 @@ A randomly-generated UUID is returned.
693691
| *Returns* 3+| `INTEGER`
694692
|===
695693

694+
[NOTE]
695+
To calculate the length of a `PATH`, see xref:functions/scalar.adoc#functions-length[`length()`].
696+
696697
.Considerations
697698
|===
698699

@@ -811,8 +812,8 @@ RETURN startNode(r)
811812
|===
812813
813814
| +startNode(r)+
814-
| {name:"Alice",age:38,eyes:"brown"}
815-
| {name:"Alice",age:38,eyes:"brown"}
815+
| {name: "Alice", age: 38, eyes: "Brown"}
816+
| {name: "Alice", age: 38, eyes: "Brown"}
816817
1+d|Rows: 2
817818
818819
|===

0 commit comments

Comments
 (0)