Cypher Expressions, Variables, and Parameters
This section describes AnzoGraph compatibility with Cypher expression, variables, and parameter features based on the Cypher Query Language Reference:
- Expressions (Partially Supported)
- CASE expressions (Supported)
- Variables (Supported)
- Parameters (Not Supported)
Expressions (Partially Supported)
Valid expressions in Cipher may include or be specified as any of the following:
- A decimal (integer or double) literal. For example: 13, -40000, 3.14, 6.022E23.
- A hexadecimal integer literal (starting with 0x). For example: 0x13zf, 0xFC3A9, -0x66eff.
- An octal integer literal (starting with zero). For example: 01372, 02127, -05671.
The current AnzoGraph release does not support hex and octal literals.
- A string literal. For example: 'Hello', "World".
- A boolean literal. For example: true, false, TRUE, FALSE.
- A variable. For example: n, x, rel, myFancyVariable, .
- A property. For example: n.prop, x.prop, rel.thisProperty, myFancyVariable.
- A dynamic property. For example: n["prop"], rel[n.city + n.zip], map[coll[0]].
- A parameter. For example: $param, $0
- A list of expressions. For example: ['a', 'b'], [1, 2, 3], ['a', 2, n.property, $param], [ ].
- A function call. For example: length(p), nodes(p).
- An aggregate function. For example: avg(x.prop), count(*).
- A path-pattern. For example: (a)-[]->()<-[]-(b).
- An operator application. For example: 1 + 2 and 3 < 4.
- A predicate expression that returns true or false. For example: a.prop = 'Hello', length(p) > 36 10, exists(a.name).
- A case-sensitive string matching expression. For example: a.surname STARTS WITH 'Sven', a.surname ENDS WITH 'son' or a.surname CONTAINS 'son'
- A CASE expression.
Escape Characters
String literals can contain the following escape sequences:
Character | Description |
---|---|
\t | Tab |
\b | Backspace |
\n | Newline |
\r | Carriage return |
\f | Form feed |
\' | Single quote |
\" | Double quote |
\\ | Backslash |
\uxxxx | Unicode UTF-16 code point (4 hex digits must follow the \u) |
\Uxxxxxxxx | Unicode UTF-32 code point (8 hex digits must follow the \U) |
CASE expressions (Supported)
Generic conditional expressions may be expressed using the well-known CASE construct. For example:
CASE test WHEN value THEN result [WHEN ...] [ELSE default] END
Two variants of CASE exist within Cypher: the simple form, which allows an expression to be compared against multiple values, and the generic form, which allows multiple conditional statements to be expressed.
Variables (Supported)
When you reference parts of a pattern or a query, you do so by naming them. The names you give the different parts are called variables. For example:
MATCH (n)-[]->(b) RETURN b
In this example, the variables are n and b.
Variable names are case-sensitive, and can contain underscores and alphanumeric characters (a-z, 0-9), but must always start with a letter. To include other characters are needed, you can escape them with the single back quote ( ` ) character. The same rule applies to property names.
Parameters (Not Supported)
The Cypher language specification supports querying with parameters. However, the current AnzoGraph release does not support them.