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.
See also Section 11.1.2, “Comparison operators”.
Tests whether a predicate holds for all element of this collection.
Syntax: ALL(identifier in collection WHERE predicate)
Arguments:
Query.
START a=node(3), b=node(1) MATCH p=a-[*1..3]->b WHERE all(x in nodes(p) WHERE x.age > 30) RETURN p
All nodes in the returned paths will have an age
property of at least 30.
Result
p |
---|
1 row |
|
Tests whether a predicate holds for at least one element in the collection.
Syntax: ANY(identifier in collection WHERE predicate)
Arguments:
Query.
START a=node(2) WHERE any(x in a.array WHERE x = "one") RETURN a
All nodes in the returned paths has at least one one
value set in the array property named array
.
Returns true if the predicate holds for no element in the collection.
Syntax: NONE(identifier in collection WHERE predicate)
Arguments:
Query.
START n=node(3) MATCH p=n-[*1..3]->b WHERE NONE(x in nodes(p) WHERE x.age = 25) RETURN p
No nodes in the returned paths has a age
property set to 25
.
Result
p |
---|
2 rows |
|
|
Returns true if the predicate holds for exactly one of the elements in the collection.
Syntax: SINGLE(identifier in collection WHERE predicate)
Arguments:
Query.
START n=node(3) MATCH p=n-->b WHERE SINGLE(var in nodes(p) WHERE var.eyes = "blue") RETURN p
Exactly one node in every returned path will have the eyes
property set to "blue"
.
Result
p |
---|
1 row |
|
Copyright © 2014 Neo Technology