Skip to content

Commit

Permalink
Clean up some function pages (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
JPryce-Aklundh authored Sep 9, 2024
1 parent 3f51cb2 commit a1a1084
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 397 deletions.
92 changes: 1 addition & 91 deletions modules/ROOT/images/graph_list_functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 1 addition & 99 deletions modules/ROOT/images/graph_numeric_functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 1 addition & 91 deletions modules/ROOT/images/graph_scalar_functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 1 addition & 40 deletions modules/ROOT/images/graph_spatial_functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion modules/ROOT/pages/functions/aggregating.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To learn more about how Cypher handles aggregations performed on zero rows, refe

The following graph is used for the examples below:

image::graph_aggregating_functions.svg[]
image::graph_aggregating_functions.svg[role="middle", width="700"]

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

Expand Down
31 changes: 16 additions & 15 deletions modules/ROOT/pages/functions/list.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ List functions return lists of different data entities.

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].

[[example-graph]]
== Example graph

The following graph is used for the examples below:

image:graph_list_functions.svg[]
image::graph_list_functions.svg[role="middle", width="700"]

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

[source, cypher, role=test-setup]
----
CREATE
(alice:Person:Developer {name:'Alice', age: 38, eyes: 'brown'}),
(bob {name: 'Bob', age: 25, eyes: 'blue'}),
(charlie {name: 'Charlie', age: 53, eyes: 'green'}),
(daniel {name: 'Daniel', age: 54, eyes: 'brown'}),
(eskil {name: 'Eskil', age: 41, eyes: 'blue', array: ['one', 'two', 'three']}),
(alice:Developer {name:'Alice', age: 38, eyes: 'Brown'}),
(bob:Administrator {name: 'Bob', age: 25, eyes: 'Blue'}),
(charlie:Administrator {name: 'Charlie', age: 53, eyes: 'Green'}),
(daniel:Adminstrator {name: 'Daniel', age: 54, eyes: 'Brown'}),
(eskil:Designer {name: 'Eskil', age: 41, eyes: 'blue', likedColors: ['Pink', 'Yellow', 'Black']}),
(alice)-[:KNOWS]->(bob),
(alice)-[:KNOWS]->(charlie),
(bob)-[:KNOWS]->(daniel),
Expand Down Expand Up @@ -68,7 +69,7 @@ A `LIST<STRING>` containing the names of all the properties on the node bound to
|===
| keys(a)
| ["eyes","name","age"]
| ["eyes", "name", "age"]
1+d|Rows: 1
|===
Expand Down Expand Up @@ -115,7 +116,7 @@ A `LIST<STRING>` containing all the labels of the node bound to `a` is returned.
|===
| labels(a)
| ["Person","Developer"]
| ["Developer"]
1+d|Rows: 1
|===
Expand Down Expand Up @@ -160,8 +161,8 @@ A `LIST<NODE>` containing all the nodes in the path `p` is returned.
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| +nodes(p)+
| +[(:Person:Developer {name: "Alice",eyes: "brown",age: 38}), ({name: "Bob",eyes: "blue",age: 25}), ({array: ['one', 'two', 'three'],name: "Eskil",eyes: "blue",age: 41})]+
| nodes(p)
| [(: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})]
1+d|Rows: 1
|===
Expand Down Expand Up @@ -367,17 +368,17 @@ RETURN reverse(ids)
[source, cypher]
----
MATCH (a) WHERE a.name = 'Eskil'
RETURN a.array, tail(a.array)
RETURN a.likedColors, tail(a.likedColors)
----
The property named `array` and a `LIST<ANY>` comprising all but the first element of the `array` property are returned.
The property named `likedColors` and a `LIST<ANY>` comprising all but the first element of the `likedColors` property are returned.
.Result
[role="queryresult",options="header,footer",cols="2*<m"]
|===
| a.array | tail(a.array)
| ["one","two","three"] | ["two","three"]
| a.likedColors | tail(a.likedColors)
| ["Pink", "Yellow", "Black"] | ["Yellow", "Black"]
2+d|Rows: 1
|===
Expand Down
23 changes: 13 additions & 10 deletions modules/ROOT/pages/functions/mathematical-numeric.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@
Numeric mathematical functions operate on numeric expressions only, and will return an error if used on any other values.
See also xref::syntax/operators.adoc#query-operators-mathematical[Mathematical operators].

[[example-graph]]
== Example graph

The following graph is used for the examples below:

image:graph_numeric_functions.svg[]
image::graph_numeric_functions.svg[role="middle", width="700"]

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

////
[source, cypher, role=test-setup]
----
CREATE
(alice:A {name:'Alice', age: 38, eyes: 'brown'}),
(bob:B {name: 'Bob', age: 25, eyes: 'blue'}),
(charlie:C {name: 'Charlie', age: 53, eyes: 'green'}),
(daniel:D {name: 'Daniel', age: 54, eyes: 'brown'}),
(eskil:E {name: 'Eskil', age: 41, eyes: 'blue', array: ['one', 'two', 'three']}),
(alice:Developer {name:'Alice', age: 38, eyes: 'Brown'}),
(bob:Administrator {name: 'Bob', age: 25, eyes: 'Blue'}),
(charlie:Administrator {name: 'Charlie', age: 53, eyes: 'Green'}),
(daniel:Adminstrator {name: 'Daniel', age: 54, eyes: 'Brown'}),
(eskil:Designer {name: 'Eskil', age: 41, eyes: 'blue', likedColors: ['Pink', 'Yellow', 'Black']}),
(alice)-[:KNOWS]->(bob),
(alice)-[:KNOWS]->(charlie),
(bob)-[:KNOWS]->(daniel),
(charlie)-[:KNOWS]->(daniel),
(bob)-[:MARRIED]->(eskil)
----
////


[[functions-abs]]
== abs()
Expand Down Expand Up @@ -55,7 +57,8 @@ CREATE
.Query
[source, cypher, indent=0]
----
MATCH (a), (e) WHERE a.name = 'Alice' AND e.name = 'Eskil' RETURN a.age, e.age, abs(a.age - e.age)
MATCH (a), (e) WHERE a.name = 'Alice' AND e.name = 'Eskil'
RETURN a.age, e.age, abs(a.age - e.age)
----
The absolute value of the age difference is returned.
Expand Down
65 changes: 33 additions & 32 deletions modules/ROOT/pages/functions/scalar.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,29 @@

Scalar functions return a single value.

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

Function `length()`:: Only works for xref::functions/scalar.adoc#functions-length[paths].
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].
====
The following graph is used for the examples below:

image:graph_scalar_functions.svg[]
image::graph_scalar_functions.svg[role="middle", width="700"]

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

////
[source, cypher, role=test-setup]
----
CREATE
(alice:Developer {name:'Alice', age: 38, eyes: 'brown'}),
(bob {name: 'Bob', age: 25, eyes: 'blue'}),
(charlie {name: 'Charlie', age: 53, eyes: 'green'}),
(daniel {name: 'Daniel', age: 54, eyes: 'brown'}),
(eskil {name: 'Eskil', age: 41, eyes: 'blue', liked_colors: ['pink', 'yellow', 'black']}),
(alice:Developer {name:'Alice', age: 38, eyes: 'Brown'}),
(bob:Administrator {name: 'Bob', age: 25, eyes: 'Blue'}),
(charlie:Administrator {name: 'Charlie', age: 53, eyes: 'Green'}),
(daniel:Adminstrator {name: 'Daniel', age: 54, eyes: 'Brown'}),
(eskil:Designer {name: 'Eskil', age: 41, eyes: 'blue', likedColors: ['Pink', 'Yellow', 'Black']}),
(alice)-[:KNOWS]->(bob),
(alice)-[:KNOWS]->(charlie),
(bob)-[:KNOWS]->(daniel),
(charlie)-[:KNOWS]->(daniel),
(bob)-[:MARRIED]->(eskil)
----
////


[role=label--new-5.13]
[[functions-char_length]]
Expand Down Expand Up @@ -162,7 +158,7 @@ RETURN coalesce(a.hairColor, a.eyes)
|===
| coalesce(a.hairColor, a.eyes)
| "brown"
| "Brown"
1+d|Rows: 1
|===
Expand Down Expand Up @@ -282,8 +278,8 @@ RETURN endNode(r)
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| endNode(r)
| {name:"Bob",age:25,eyes:"blue"}
| {name:"Charlie",age:53,eyes:"green"}
| {name: "Bob", age: 25, eyes: "Blue"}
| {name: "Charlie", age: 53, eyes: "Green"}
1+d|Rows: 2
|===
Expand Down Expand Up @@ -320,7 +316,7 @@ RETURN endNode(r)
----
MATCH (a)
WHERE a.name = 'Eskil'
RETURN a.liked_colors, head(a.liked_colors)
RETURN a.likedColors, head(a.likedColors)
----
The first element in the list is returned.
Expand All @@ -329,8 +325,8 @@ The first element in the list is returned.
[role="queryresult",options="header,footer",cols="2*<m"]
|===
| a.liked_colors+ | +head(a.liked_colors)
| ["pink","yellow","black"] | "pink"
| a.likedColors+ | +head(a.likedColors)
| ["Pink", "Yellow", "Black"] | "Pink"
2+d|Rows: 1
|===
Expand Down Expand Up @@ -446,7 +442,7 @@ The node identifier for each of the nodes is returned.
----
MATCH (a)
WHERE a.name = 'Eskil'
RETURN a.liked_colors, last(a.liked_colors)
RETURN a.likedColors, last(a.likedColors)
----
The last element in the list is returned.
Expand All @@ -456,7 +452,7 @@ The last element in the list is returned.
|===
| a.liked_colors | last(a.liked_colors)
| ["pink","yellow","black"] | "black"
| ["Pink", "Yellow", "Black"] | "Black"
2+d|Rows: 1
|===
Expand All @@ -483,6 +479,8 @@ The last element in the list is returned.

|===

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

.+length()+
======
Expand Down Expand Up @@ -583,7 +581,7 @@ The `nullIf()` function can be used in conjunction with the `coalesce()` functio
[source, cypher, indent=0]
----
MATCH (a)
RETURN a.name AS name, coalesce(nullIf(a.eyes, "brown"), "hazel") AS eyeColor
RETURN a.name AS name, coalesce(nullIf(a.eyes, "Brown"), "Hazel") AS eyeColor
----
Expand All @@ -592,11 +590,11 @@ RETURN a.name AS name, coalesce(nullIf(a.eyes, "brown"), "hazel") AS eyeColor
|===
| name | eyeColor
| "Alice" | "hazel"
| "Bob" | "blue"
| "Charlie" | "green"
| "Daniel" | "hazel"
| "Eskil" | "blue"
| "Alice" | "Hazel"
| "Bob" | "Blue"
| "Charlie" | "Green"
| "Daniel" | "Hazel"
| "Eskil" | "Blue"
2+d|Rows: 5
|===
Expand Down Expand Up @@ -640,7 +638,7 @@ RETURN properties(p)
|===
| properties(p)
| {"city":"Berlin","name":"Stefan"}
| {"city": "Berlin", "name": "Stefan"}
1+d|Rows: 1
|===
Expand Down Expand Up @@ -693,6 +691,9 @@ A randomly-generated UUID is returned.
| *Returns* 3+| `INTEGER`
|===

[NOTE]
To calculate the length of a `PATH`, see xref:functions/scalar.adoc#functions-length[`length()`].

.Considerations
|===

Expand Down Expand Up @@ -811,8 +812,8 @@ RETURN startNode(r)
|===
| +startNode(r)+
| {name:"Alice",age:38,eyes:"brown"}
| {name:"Alice",age:38,eyes:"brown"}
| {name: "Alice", age: 38, eyes: "Brown"}
| {name: "Alice", age: 38, eyes: "Brown"}
1+d|Rows: 2
|===
Expand Down
Loading

0 comments on commit a1a1084

Please sign in to comment.