Functions

Functions are grouped by usage. Except for the COALESCE function, all of these functions return a null value if any argument has a null value.

COALESCE

The COALESCE function takes any number of parameters (at least one) and returns the first non-null value. It returns a null value only in case all the parameters have null values.

Usually, this function is used every time you have to deal with null values and want a fallback value in case of a null value. Consider the following query:

MATCH (aa:Book) 
WHERE 'novel' IN COALESCE(aa.tags, ['novel']) 
RETURN aa.title

This query returns all books that have novel in their tags, but will return all the books that do not have no tags set as well. In fact, if a book doesn't have the tags property, the ...

Get Learning Cypher now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.