Here is a list of the functions in Cypher, seperated into three different sections: Predicates, Scalar functions and Aggregated functions
Graph
Predicates are boolean functions that return true or false for a given set of input.
They are most commonly used to filter out subgraphs in the WHERE
part of a query.
Tests the predicate closure to see if all items in the iterable match.
Syntax: ALL(identifier in iterable : predicate)
Arguments:
_
(underscore) will be used.
Query
START a=node(3), b=node(1) MATCH p=a-[*1..3]->b WHERE all(x in nodes(p) : x.age > 30) RETURN p
All nodes in the path.
Tests the predicate closure to see if at least one item in the iterable match.
Syntax: ANY(identifier in iterable : predicate)
Arguments:
_
(underscore) will be used.
Query
START a=node(3) MATCH p=a-[*1..3]->b WHERE any(x in nodes(p) : x.eyes = "blue") RETURN p
All nodes in the path.
Result
p |
---|
3 rows, 2 ms |
|
|
|
Tests the predicate closure to see if no items in the iterable match. If even one matches, the function returns false.
Syntax: NONE(identifier in iterable : predicate)
Arguments:
_
(underscore) will be used.
Query
START n=node(3) MATCH p=n-[*1..3]->b WHERE NONE(x in nodes(p) : x.age = 25) RETURN p
All nodes in the path.
Returns true if the closure predicate matches exactly one of the items in the iterable.
Syntax: SINGLE(identifier in iterable : predicate)
Arguments:
_
(underscore) will be used.
Query
START n=node(3) MATCH p=n-->b WHERE SINGLE(var in nodes(p) : var.eyes = "blue") RETURN p
All nodes in the path.
To return or filter on the length of a path, use the special property LENGTH
Syntax: LENGTH( iterable )
Arguments:
Query
START a=node(3) MATCH p=a-->b-->c RETURN length(p)
The length of the path p.
Returns a string representation of the relationship type.
Syntax: TYPE( relationship )
Arguments:
Query
START n=node(3) MATCH (n)-[r]->() RETURN type(r)
The relationship type of r.
Returns the id of the relationship or node
Syntax: ID( property-container )
Arguments:
Query
START a=node(3, 4, 5) RETURN ID(a)
The node id for three nodes.
Iterable functions return an iterable of things - nodes in a path, and so on.
Returns all nodes in a path
Syntax: NODES( path )
Arguments:
Query
START a=node(3), c=node(2) MATCH p=a-->b-->c RETURN NODES(p)
All the nodes in the path p.
Copyright © 2011 Neo Technology