List Functions

Data Setup

SELECT * from cypher('graph_name', $$
CREATE (A:Person {name: 'Alice', age: 38, eyes: 'brown'}),
	(B:Person {name: 'Bob', age: 25, eyes: 'blue'}),
	(C:Person {name: 'Charlie', age: 53, eyes: 'green'}),
	(D:Person {name: 'Daniel', age: 54, eyes: 'brown'}),
	(E:Person {name: 'Eskil', age: 41, eyes: 'blue', array: ['one', 'two', 'three']}),
	(A)-[:KNOWS]->(B),
	(A)-[:KNOWS]->(C),
	(B)-[:KNOWS]->(D),
	(C)-[:KNOWS]->(D),
	(B)-[:KNOWS]->(E)
$$) as (result agtype);

keys

keys returns a list containing the string representations for all the property names of a vertex, edge, or map.

Syntax:keys(expression)

Returns:

An Agtype list containing string agtype elements

Arguments:

Considerations:

  • keys(null) returns null.

Query:

SELECT * from cypher('graph_name', $$
	MATCH (a)
	WHERE a.name = 'Alice'
	RETURN keys(a)
$$) as (result agtype);

A list containing the names of all the properties on the vertex bound to a is returned.

Result:

range

range() returns a list comprising all integer values within a range bounded by a start value start and end value end, where the difference step between any two consecutive values is constant; i.e. an arithmetic progression. The range is inclusive, and the arithmetic progression will therefore always contain start and—depending on the values of start, step and end—end.

Syntax:range(start, end [, step])

Returns:

An Agtype list containing edge entities

Arguments:

Query:

SELECT *
FROM cypher('graph_name', $$
	RETURN range(0, 10), range(2, 18, 3)
$$) as (no_step agtype, step agtype);

Two lists of numbers in the given ranges are returned.

Result:

labels

labels returns a list containing the string representations for all the labels of a node.

Syntax:labels(vertex)

Returns:

An Agtype list containing String elements

Arguments:

Considerations:

  • labels(null) returns null.

Query:

SELECT *
FROM cypher('graph_name', $$
	MATCH (a)
	WHERE a.name = 'Alice'
	RETURN labels(a)
$$) as (edges agtype);

A list containing all the labels of the node bound to a is returned.

Result:

relationships

relationships() returns a list containing all the relationships in a path.

Syntax:relationships(path)

Returns:

An Agtype list containing edge entities

Arguments:

Considerations:

  • relationships(null) returns null.

Query:

SELECT *
FROM cypher('graph_name', $$
	MATCH p = (a)-[]->(b)-[]->(c)
	WHERE a.name = 'Alice' AND c.name = 'Eskil'
	RETURN relationships(p)
$$) as (edges agtype);

A list containing all the edges in the path p is returned.

Result: