Scalar functions
The |
The |
The function |
Functions:
N0 [ label = "{Developer|name = \'Alice\'\leyes = \'brown\'\lage = 38\l}" ] N0 -> N2 [ color = "#2e3436" fontcolor = "#2e3436" label = "KNOWS\n" ] N0 -> N1 [ color = "#2e3436" fontcolor = "#2e3436" label = "KNOWS\n" ] N1 [ label = "name = \'Bob\'\leyes = \'blue\'\lage = 25\l" ] N1 -> N4 [ color = "#4e9a06" fontcolor = "#4e9a06" label = "MARRIED\n" ] N1 -> N3 [ color = "#2e3436" fontcolor = "#2e3436" label = "KNOWS\n" ] N2 [ label = "name = \'Charlie\'\leyes = \'green\'\lage = 53\l" ] N2 -> N3 [ color = "#2e3436" fontcolor = "#2e3436" label = "KNOWS\n" ] N3 [ label = "name = \'Daniel\'\leyes = \'brown\'\lage = 54\l" ] N4 [ label = "array = \[\'one\', \'two\', \'three\'\]\lname = \'Eskil\'\leyes = \'blue\'\lage = 41\l" ]
coalesce()
coalesce()
returns the first non-null
value in the given list of expressions.
Syntax: coalesce(expression [, expression]*)
Returns:
The type of the value returned will be that of the first non- |
Arguments:
Name | Description |
---|---|
|
An expression which may return |
Considerations:
|
MATCH (a)
WHERE a.name = 'Alice'
RETURN coalesce(a.hairColor, a.eyes)
coalesce(a.hairColor, a.eyes) |
---|
|
1 row |
endNode()
endNode()
returns the end node of a relationship.
Syntax: endNode(relationship)
Returns:
A Node. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a relationship. |
Considerations:
|
MATCH (x:Developer)-[r]-()
RETURN endNode(r)
endNode(r) |
---|
|
|
2 rows |
head()
head()
returns the first element in a list.
Syntax: head(list)
Returns:
The type of the value returned will be that of the first element of |
Arguments:
Name | Description |
---|---|
|
An expression that returns a list. |
Considerations:
|
If the first element in |
MATCH (a)
WHERE a.name = 'Eskil'
RETURN a.array, head(a.array)
The first element in the list is returned.
a.array | head(a.array) |
---|---|
|
|
1 row |
id()
The function id()
returns a node or a relationship identifier, unique by an object type and a database.
Therefore, it is perfectly allowable for id()
to return the same value for both nodes and relationships in the same database.
For examples on how to get a node and a relationship by ID, see Get node or relationship by id.
Neo4j implements the id so that:
|
Syntax: id(expression)
Returns:
An Integer. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a node or a relationship. |
Considerations:
|
MATCH (a)
RETURN id(a)
The node identifier for each of the nodes is returned.
id(a) |
---|
|
|
|
|
|
5 rows |
last()
last()
returns the last element in a list.
Syntax: last(expression)
Returns:
The type of the value returned will be that of the last element of |
Arguments:
Name | Description |
---|---|
|
An expression that returns a list. |
Considerations:
|
If the last element in |
MATCH (a)
WHERE a.name = 'Eskil'
RETURN a.array, last(a.array)
The last element in the list is returned.
a.array | last(a.array) |
---|---|
|
|
1 row |
length()
length()
returns the length of a path.
Syntax: length(path)
Returns:
An Integer. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a path. |
Considerations:
|
MATCH p =(a)-->(b)-->(c)
WHERE a.name = 'Alice'
RETURN length(p)
The length of the path p
is returned.
length(p) |
---|
|
|
|
3 rows |
properties()
properties()
returns a map containing all the properties of a node or relationship.
If the argument is already a map, it is returned unchanged.
Syntax: properties(expression)
Returns:
A Map. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a node, a relationship, or a map. |
Considerations:
|
CREATE (p:Person { name: 'Stefan', city: 'Berlin' })
RETURN properties(p)
properties(p) |
---|
|
1 row |
randomUUID()
randomUUID()
returns a randomly-generated Universally Unique Identifier (UUID), also known as a Globally Unique Identifier (GUID).
This is a 128-bit value with strong guarantees of uniqueness.
Syntax: randomUUID()
Returns:
A String. |
RETURN randomUUID() AS uuid
uuid |
---|
|
1 row |
A randomly-generated UUID is returned.
size()
size()
returns the number of elements in a list.
Syntax: size(list)
Returns:
An Integer. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a list. |
Considerations:
|
RETURN size(['Alice', 'Bob'])
size(['Alice', 'Bob']) |
---|
|
1 row |
The number of elements in the list is returned.
size() applied to pattern expression
This is the same size()
method as described above, but instead of passing in a list directly, a pattern expression can be provided that can be used in a match query to provide a new set of results.
These results are a list of paths.
The size of the result is calculated, not the length of the expression itself.
Syntax: size(pattern expression)
Arguments:
Name | Description |
---|---|
|
A pattern expression that returns a list. |
MATCH (a)
WHERE a.name = 'Alice'
RETURN size((a)-->()-->()) AS fof
fof |
---|
|
1 row |
The number of paths matching the pattern expression is returned.
size() applied to string
size()
returns the number of Unicode characters in a string.
Syntax: size(string)
Returns:
An Integer. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a string value. |
Considerations:
|
MATCH (a)
WHERE size(a.name)> 6
RETURN size(a.name)
size(a.name) |
---|
|
1 row |
The number of characters in the string 'Charlie' is returned.
startNode()
startNode()
returns the start node of a relationship.
Syntax: startNode(relationship)
Returns:
A Node. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a relationship. |
Considerations:
|
MATCH (x:Developer)-[r]-()
RETURN startNode(r)
startNode(r) |
---|
|
|
2 rows |
timestamp()
timestamp()
returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
Syntax: timestamp()
Returns:
An Integer. |
Considerations:
|
RETURN timestamp()
The time in milliseconds is returned.
timestamp() |
---|
|
1 row |
toBoolean()
toBoolean()
converts a string value to a boolean value.
Syntax: toBoolean(expression)
Returns:
A Boolean. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a boolean or string value. |
Considerations:
|
If |
If the parsing fails, |
RETURN toBoolean('TRUE'), toBoolean('not a boolean')
toBoolean('TRUE') | toBoolean('not a boolean') |
---|---|
|
|
1 row |
toFloat()
toFloat()
converts an integer or string value to a floating point number.
Syntax: toFloat(expression)
Returns:
A Float. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a numeric or string value. |
Considerations:
|
If |
If the parsing fails, |
RETURN toFloat('11.5'), toFloat('not a number')
toFloat('11.5') | toFloat('not a number') |
---|---|
|
|
1 row |
toInteger()
toInteger()
converts a floating point or string value to an integer value.
Syntax: toInteger(expression)
Returns:
An Integer. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a numeric or string value. |
Considerations:
|
If |
If the parsing fails, |
RETURN toInteger('42'), toInteger('not a number')
toInteger('42') | toInteger('not a number') |
---|---|
|
|
1 row |
type()
type()
returns the string representation of the relationship type.
Syntax: type(relationship)
Returns:
A String. |
Arguments:
Name | Description |
---|---|
|
An expression that returns a relationship. |
Considerations:
|
MATCH (n)-[r]->()
WHERE n.name = 'Alice'
RETURN type(r)
The relationship type of r
is returned.
type(r) |
---|
|
|
2 rows |