Skip to content

Predicate Functions

Introduction

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.

The following graph is used in the example below:

Example Graph

Run this Cypher in Quine to create the sample graph.

CREATE
  (alice:Person:Developer {name:'Alice', age: 38, eyes: 'brown'}),
  (bob {name: 'Bob', surname: 'Smith', age: 25, eyes: 'blue'}),
  (charlie {name: 'Charlie', surname: 'Brown', age: 53, eyes: 'green'}),
  (daniel {name: 'Daniel', age: 54, eyes: 'brown'}),
  (eskil {name: 'Eskil', age: 41, eyes: 'blue', array: ['one', 'two', 'three']}),
  (alice)-[:KNOWS]->(bob),
  (alice)-[:KNOWS]->(charlie),
  (bob)-[:KNOWS]->(daniel),
  (charlie)-[:KNOWS]->(daniel),
  (bob)-[:MARRIED]->(eskil)

property IS NOT NULL

property IS NOT NULL returns true if the specified property exists in the node, relationship or map.

Syntax: property IS NOT NULL

Returns: A boolean

Arguments:

Name Description
property A property (in the form 'variable.prop').

Sample:

MATCH (n)
WHERE n.surname IS NOT NULL
RETURN n.name AS name, n.surname AS surname

Note

Be sure to submit the query as a text query using Shift+Enter.

The names and surnames of all nodes with a surname property are returned.

{
  "columns": [
    "name",
    "surname"
  ],
  "results": [
    [
      "Charlie",
      "Brown"
    ],
    [
      "Bob",
      "Smith"
    ]
  ]
}