Cypher Operators


Precedence

Operators are listed from highest to lowest precedence. Operators at the same level associate left-to-right unless noted.

LevelOperator(s)Associativity
1 (highest). (property access), [ (subscript/slice)Left
2Unary - (negation), NOTRight
3*, /, %Left
4+, -Left
5=, <>, <, >, <=, >=Left
6IS NULL, IS NOT NULL
7STARTS WITH, ENDS WITH, CONTAINS, =~, INLeft
8ANDLeft
9XORLeft
10 (lowest)ORLeft

Use parentheses to override precedence.


Arithmetic Operators

OperatorSyntaxDescriptionExampleResult
Additiona + bNumeric addition; string concatenation2 + 35
Subtractiona - bNumeric subtraction10 - 46
Multiplicationa * bNumeric multiplication3 * 412
Divisiona / bNumeric division; integer inputs yield float7 / 23.5
Moduloa % bRemainder10 % 31
Unary negation-aNegate a number-n.agenegated

Type behavior

  • Integer + Integer → Integer
  • Integer + Float → Float
  • String + String → String concatenation
  • Any arithmetic with nullnull

Comparison Operators

OperatorSyntaxDescription
Equalsa = bValue equality
Not equalsa <> bValue inequality
Less thana < b
Greater thana > b
Less or equala <= b
Greater or equala >= b

Type behavior

  • Comparing null with any operator returns null (not true or false).
  • Comparisons between incompatible types return null.
  • Strings compare lexicographically.

Examples

WHERE n.age >= 18
WHERE n.name <> 'Alice'
WHERE n.score = 100

Boolean Operators

OperatorSyntaxDescription
ANDa AND btrue if both operands are true
ORa OR btrue if at least one operand is true
NOTNOT aLogical negation
XORa XOR btrue if exactly one operand is true

Three-valued logic (null behavior)

aba AND ba OR b
truenullnulltrue
falsenullfalsenull
nullnullnullnull

NOT nullnull

Examples

WHERE n.age > 18 AND n.active = true
WHERE n.role = 'admin' OR n.role = 'mod'
WHERE NOT n.deleted
WHERE (n.a = 1) XOR (n.b = 1)

String Operators

OperatorSyntaxDescriptionExample
Starts withs STARTS WITH prefixPrefix matchn.name STARTS WITH 'Al'
Ends withs ENDS WITH suffixSuffix matchn.email ENDS WITH '.com'
Containss CONTAINS subSubstring searchn.bio CONTAINS 'engineer'
Regex matchs =~ patternPCRE regex; full-string matchn.name =~ 'Al.*'
Concatenations1 + s2Join two stringsn.first + ' ' + n.last

All string operators are case-sensitive. =~ uses PCRE syntax via the regexp() SQL function registered by the extension.

Examples

WHERE n.name STARTS WITH 'A'
WHERE n.email ENDS WITH '.org'
WHERE n.bio CONTAINS 'graph'
WHERE n.code =~ '[A-Z]{3}[0-9]+'

List Operators

OperatorSyntaxDescriptionExample
Membershipx IN listtrue if x is an element of listn.role IN ['admin', 'mod']
Concatenationlist1 + list2Combine two lists[1,2] + [3,4][1,2,3,4]
Index accesslist[index]Element at 0-based index; negative index counts from endlist[0], list[-1]
Slicelist[start..end]Sublist from start (inclusive) to end (exclusive)list[1..3]

Examples

WHERE n.status IN ['active', 'pending']
RETURN [1, 2] + [3, 4]       -- [1, 2, 3, 4]
RETURN [10, 20, 30][1]       -- 20
RETURN [10, 20, 30, 40][1..3] -- [20, 30]

Null Operators

OperatorSyntaxDescription
Is nullexpr IS NULLtrue if expression is null
Is not nullexpr IS NOT NULLtrue if expression is not null

Examples

WHERE n.email IS NOT NULL
WHERE n.deletedAt IS NULL

Property Access Operators

OperatorSyntaxDescription
Dot notationentity.propertyAccess a property by name
String subscriptentity['property']Access a property by string key
Nested dotn.a.bAccess nested JSON field (requires a to be a JSON-type property)

String-key subscript (n['key']) is normalized at transform time to the same SQL as dot notation. Both forms are equivalent.

Examples

RETURN n.name
RETURN n['name']
RETURN n.address.city     -- requires address stored as JSON