12.1. Operators

12.1.1. Mathematical operators
12.1.2. Comparison operators
12.1.3. Boolean operators
12.1.4. String operators
12.1.5. Collection operators
12.1.6. Property operators

12.1.1. Mathematical operators

The mathematical operators are +, -, *, / and %.

12.1.2. Comparison operators

The comparison operators are =, <>, <, >, <=, >=.

12.1.3. Boolean operators

The boolean operators are AND, `OR, NOT.

12.1.4. String operators

Strings can be concatenated using the + operator.

12.1.5. Collection operators

Collections can be concatenated using the + operator.

12.1.6. Property operators

Since Neo4j is a schema-free graph database, Cypher has two special operators: ? and !.

They are used on properties, and are used to deal with missing values. A comparison on a property that does not exist would normally cause an error. Instead of having to always check if the property exists before comparing its value with something else, the special property operators can be used. The question mark makes the comparison always return true if the property is missing, and the exclamation mark makes the comparator return false.

This predicate will evaluate to true if n.prop is missing.

WHERE n.prop? = "foo"

This predicate will evaluate to false if n.prop is missing.

WHERE n.prop! = "foo"

[Warning]Warning

Mixing the two in the same comparison will lead to unpredictable results.

This is really syntactic sugar that expands to this:

WHERE n.prop? = "foo"WHERE (not(has(n.prop)) OR n.prop = "foo")

WHERE n.prop! = "foo"WHERE (has(n.prop) AND n.prop = "foo")