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.
Exists(Property)
exists() returns true if the specified property exists in the node, relationship or map. This is different from the EXISTS clause.
Syntax: exists(property)
Returns:
An agtype boolean
Arguments:
| Name | Description |
| property | A property from a vertex or edge |
Query
SELECT *FROM cypher('graph_name', $$MATCH (n)WHERE exists(n.surname)RETURN n.first_name, n.last_name$$) as (first_name agtype, last_name agtype);
Results:
| first_name | last_name |
| ‘John | ‘Smith’ |
| ‘Patty’ | ‘Patterson’ |
| 2 row(s) returned | |
Exists(Path)
EXISTS(path) returns true if for the given path, there already exists the given path.
SELECT *FROM cypher('graph_name', $$MATCH (n)WHERE exists((n)-[]-({name: 'Willem Defoe'}))RETURN n.full_name$$) as (full_name agtype);
Results:
| full_name | |
| ‘Toby Maguire’ | |
| ‘Tom Holland’ | |
| 2 row(s) returned | |
