14.1. Operators

14.1.1. Mathematical operators
14.1.2. Comparison operators
14.1.3. String operators
14.1.4. Collection operators
14.1.5. Property operators

14.1.1. Mathematical operators

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

14.1.2. Comparison operators

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

14.1.3. String operators

Strings can be concatenated using the + operator.

14.1.4. Collection operators

Collections can be concatenated using the + operator.

14.1.5. 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")