Functions¶
Predicate Functions¶
Predicates are boolean functions that return true or false for a given set of non-null input. They are most commonly used to filter out paths in the WHERE part of a query.
all()
any()
exists()
isEmpty()
In the Movie database, we want to find who is married and who is not:
MATCH (n:Person)
WHERE exists(n.name)
RETURN
n.name AS name,
exists((n)-[:MARRIED_TO]->()) AS is_married
Aggregating Functions¶
count()¶
The function count() returns the number of values or rows, and appears in two variants:
count(*)
returns the number of matching rows.
count(expr)
returns the number of non-null values returned by an expression.
Find the different relationships in the graph:
MATCH (n)-[r]->()
RETURN type(r), count(*)
MATCH (actor:Person)-[*2]-(friend_of_friend:Person)
WHERE actor.name = 'Tom Hanks'
RETURN count(DISTINCT friend_of_friend), count(friend_of_friend)
Mathematical Functions¶
abs()
ceil()
floor()
rand()
round()