Cypher Operators

This section describes AnzoGraph compatibility with Cypher operators based on the Cypher Query Language Reference specification:

General Operators (Partially Supported)

General operators include:

  • DISTINCT – removes duplicates values.
  • Dot operator – access the property of a node, relationship or literal map.
  • Subscript operator ([ ] ) – provides dynamic property access.

The subscript operator ( [ ] ) and dynamic property access are not supported in the current AnzoGraph release.

Mathematical Operators (Supported)

The mathematical operators supported in Cypher are the following:

  • addition ( + )
  • subtraction or unary minus ( - )
  • multiplication ( * )
  • division ( / )
  • modulo division ( % )
  • exponentiation ( ^ )

Comparison Operators (Supported)

Cypher comparison operators include the following:

  • equality ( = )
  • inequality ( <> )
  • less than ( < )
  • greater than ( > )
  • less than or equal to ( <= )
  • greater than or equal to ( >= )
  • IS NULL
  • IS NOT NULL

String-specific comparison operators in Cypher include the following:

  • STARTS WITH – provides case-sensitive prefix searching on strings.
  • ENDS WITH – provides case-sensitive suffix searching on strings.
  • CONTAINS – provides case-sensitive inclusion searching in strings.

Boolean Operators (Supported)

Cypher Boolean operators, also referred to as logical operators, include the following:

  • conjunction – AND
  • disjunction – OR
  • exclusive disjunction – XOR
  • negation – NOT

String Operators (Partially Supported)

The sole string operator that Cypher supports is the plus sign (+) concatenation operator.

The plus sign (+) string concatenation operator is not supported in the current AnzoGraph release. (The CONCAT() function is supported to perform the same function.)

List Operators (Not Supported)

Cypher list operators include the concatenation plus sign ( + ) operator and the IN operator that checks if an element exists in a list.

The LIST type is not supported in the current AnzoGraph release.

Equality and Comparison of Values (Partially Supported)

Cypher supports comparing values for equality using the equals ( = ) and less-than-greater-than, not equals ( <> ) operators. Values of the same type are only equal if they have the same identical value, for example, 3 = 3.

LIST, MAP, and PATH types are not supported in the current AnzoGraph release.

Values of different types are considered equal based on the following rules:

  • Paths are treated as lists of alternating nodes and relationships; they are considered equal to all lists that contain that very same sequence of nodes and relationships.
  • Testing any value against null with either the equals ( =) or the less-than-great-than, not equal ( <> ) operators always returns null. This includes null = null and null <> null. The only way to reliably test if a value v is null is by using the special v IS NULL or v IS NOT NULL equality operators.
  • Maps are only equal if they map exactly the same keys to equal values; lists are only equal if they contain the same sequence of equal values, for example: [3, 4] = [1+2, 8/2].

All other combinations of value types cannot be compared with each other. Nodes, relationships, and literal maps also cannot be compared with each other. Attempting to specify comparisons of values that cannot be compared will return an error.

Ordering and Comparison of Values (Supported)

The following comparison operators are used to compare values for ordering:

  • <=

  • < (for ascending)

  • >=, and > (for descending)

The following details describe how the comparisons are performed:

  • Numerical values are compared for ordering using numerical order. For example, 3 < 4 is true.
  • String values are compared for ordering using lexicographic order. For example, "x" < "xy".
  • Boolean values are compared for ordering, that is false < true.
  • Comparing for ordering when one argument is null returns null. For example, null < 3 is null.

Specifying comparisons for ordering of other types of values will return an error.

Chaining Comparison Operations (Supported)

Comparisons can be chained together arbitrarily. For example, x < y <= z is equivalent to x < y AND y <= z. As a general practice, if a, b, c, ..., y, z are expressions and op1, op2, ..., opN are comparison operators, then a op1 b op2 c ... y opN z is equivalent to a op1 b and b op2 c and ... y opN z.

Related Topics