Skip to content

List functions

Function Description
keys(expr) Returns a list containing the string representations for all the property names of a vertex, edge, or map.
labels(vertex) Returns the tags of a vertex.
nodes(path) Returns a list containing all the nodes in a path.
range(start, end [, step]) A list of Integer elements.
relationships(path) Returns a list containing all the relationships in a path.
reverse(list) returns a list in which the order of all elements in the original list have been reversed.
tail(list) returns all the elements, excluding the first one.
head(list) Returns the first element of a list.
last(list) Returns the last element of a list.
coalesce(list) Returns the first not null value in a list.
reduce() See reduce() function.

Note

If the parameter is NULL, the output is undefined.

Examples

nebula> WITH [NULL, 4923, 'abc', 521, 487] AS ids RETURN reverse(ids), tail(ids), head(ids), last(ids), coalesce(ids)
+-----------------------------------+-------------------------+-----------+-----------+---------------+
| reverse(ids)                      | tail(ids)               | head(ids) | last(ids) | coalesce(ids) |
+-----------------------------------+-------------------------+-----------+-----------+---------------+
| [487, 521, "abc", 4923, __NULL__] | [4923, "abc", 521, 487] | __NULL__  | 487       | 4923          |
+-----------------------------------+-------------------------+-----------+-----------+---------------+

nebula> MATCH (a:player)-[r]->() WHERE id(a) == "player100" RETURN labels(a),  keys(r)
+------------+----------------------------+
| labels(a)  | keys(r)                    |
+------------+----------------------------+
| ["player"] | ["degree"]                 |
+------------+----------------------------+
| ["player"] | ["degree"]                 |
+------------+----------------------------+
| ["player"] | ["end_year", "start_year"] |
+------------+----------------------------+

nebula> MATCH p = (a:player)-[]->(b)-[]->(c:team) WHERE a.name == "Tim Duncan" AND c.name == "Spurs" RETURN nodes(p)
+-----------------------------------------------------------------------------------------------------------------------------------------------+
| nodes(p)                                                                                                                                      |
+-----------------------------------------------------------------------------------------------------------------------------------------------+
| [("player100" :player{age: 42, name: "Tim Duncan"}), ("player101" :player{age: 36, name: "Tony Parker"}), ("team204" :team{name: "Spurs"})]   |
+-----------------------------------------------------------------------------------------------------------------------------------------------+
| [("player100" :player{age: 42, name: "Tim Duncan"}), ("player125" :player{age: 41, name: "Manu Ginobili"}), ("team204" :team{name: "Spurs"})] |
+-----------------------------------------------------------------------------------------------------------------------------------------------+

nebula> MATCH p = (a:player)-[]->(b)-[]->(c:team) WHERE a.name == "Tim Duncan" AND c.name == "Spurs" RETURN relationships(p)
+-----------------------------------------------------------------------------------------------------------------------------+
| relationships(p)                                                                                                            |
+-----------------------------------------------------------------------------------------------------------------------------+
| [[:follow "player100"->"player101" @0 {degree: 95}], [:serve "player101"->"team204" @0 {end_year: 2018, start_year: 1999}]] |
+-----------------------------------------------------------------------------------------------------------------------------+
| [[:follow "player100"->"player125" @0 {degree: 95}], [:serve "player125"->"team204" @0 {end_year: 2018, start_year: 2002}]] |
+-----------------------------------------------------------------------------------------------------------------------------+

Last update: April 22, 2021
Back to top