3.9. Glossary of keywords

This section comprises a glossary of all the keywords — grouped by category and thence ordered lexicographically — in the Cypher query language.

3.9.1. Clauses

Clause Category Description

CALL […​YIELD]

Reading/Writing

Invoke a procedure deployed in the database.

CREATE

Writing

Create nodes and relationships.

CREATE CONSTRAINT ON (n:Label) ASSERT exists(n.property)

Schema

Create a constraint ensuring that all nodes with a particular label have a certain property.

CREATE CONSTRAINT ON (n:Label) ASSERT (n.prop1, …​, n.propN) IS NODE KEY

Schema

Create a constraint ensuring all nodes with a particular label have all the specified properties and that the combination of property values is unique; i.e. ensures existence and uniqueness.

CREATE CONSTRAINT ON ()-[r:REL_TYPE]-() ASSERT exists(r.property)

Schema

Create a constraint ensuring that all relationship with a particular type have a certain property.

CREATE CONSTRAINT ON (n:Label) ASSERT n.property IS UNIQUE

Schema

Create a constraint ensuring the uniqueness of the combination of node label and property value for a particular property key across all nodes.

CREATE INDEX ON :Label(property)

Schema

Create an index on all nodes with a particular label and a single property; i.e. create a single-property index.

CREATE INDEX ON :Label(prop1, …​, propN)

Schema

Create an index on all nodes with a particular label and multiple properties; i.e. create a composite index.

DELETE

Writing

Delete graph elements — nodes, relationships or paths. Any node to be deleted must also have all associated relationships explicitly deleted.

DETACH DELETE

Writing

Delete a node or set of nodes. All associated relationships will automatically be deleted.

DROP CONSTRAINT ON (n:Label) ASSERT exists(n.property)

Schema

Drop a constraint ensuring that all nodes with a particular label have a certain property.

DROP CONSTRAINT ON ()-[r:REL_TYPE]-() ASSERT exists(r.property)

Schema

Drop a constraint ensuring that all relationship with a particular type have a certain property.

DROP CONSTRAINT ON (n:Label) ASSERT n.property IS UNIQUE

Schema

Drop a constraint ensuring the uniqueness of the combination of node label and property value for a particular property key across all nodes.

DROP CONSTRAINT ON (n:Label) ASSERT (n.prop1, …​, n.propN) IS NODE KEY

Schema

Drop a constraint ensuring all nodes with a particular label have all the specified properties and that the combination of property values is unique.

DROP INDEX ON :Label(property)

Schema

Drop an index on all nodes with a particular label and a single property; i.e. drop a single-property index.

DROP INDEX ON :Label(prop1, …​, propN)

Schema

Drop an index on all nodes with a particular label and multiple properties; i.e. drop a composite index.

FOREACH

Writing

Update data within a list, whether components of a path, or the result of aggregation.

LIMIT

Reading sub-clause

A sub-clause used to constrain the number of rows in the output.

LOAD CSV

Importing data

Use when importing data from CSV files.

MATCH

Reading

Specify the patterns to search for in the database.

MERGE

Reading/Writing

Ensures that a pattern exists in the graph. Either the pattern already exists, or it needs to be created.

ON CREATE

Reading/Writing

Used in conjunction with MERGE, specifying the actions to take if the pattern needs to be created.

ON MATCH

Reading/Writing

Used in conjunction with MERGE, specifying the actions to take if the pattern already exists.

OPTIONAL MATCH

Reading

Specify the patterns to search for in the database while using nulls for missing parts of the pattern.

ORDER BY [ASC[ENDING] | DESC[ENDING]]

Reading sub-clause

A sub-clause following RETURN or WITH, specifying that the output should be sorted in either ascending (the default) or descending order.

REMOVE

Writing

Remove properties and labels from nodes and relationships.

RETURN …​ [AS]

Projecting

Defines what to include in the query result set.

SET

Writing

Update labels on nodes and properties on nodes and relationships.

SKIP

Reading/Writing

A sub-clause defining from which row to start including the rows in the output.

UNION

Set operations

Combines the result of multiple queries. Duplicates are removed.

UNION ALL

Set operations

Combines the result of multiple queries. Duplicates are retained.

UNWIND …​ [AS]

Projecting

Expands a list into a sequence of rows.

USING INDEX variable:Label(property)

Hint

Index hints are used to specify which index, if any, the planner should use as a starting point.

USING JOIN ON variable

Hint

Join hints are used to enforce a join operation at specified points.

USING PERIODIC COMMIT

Hint

This query hint may be used to prevent an out-of-memory error from occurring when importing large amounts of data using LOAD CSV.

USING SCAN variable:Label

Hint

Scan hints are used to force the planner to do a label scan (followed by a filtering operation) instead of using an index.

WITH …​ [AS]

Projecting

Allows query parts to be chained together, piping the results from one to be used as starting points or criteria in the next.

WHERE

Reading sub-clause

A sub-clause used to add constraints to the patterns in a MATCH or OPTIONAL MATCH clause, or to filter the results of a WITH clause.

3.9.2. Operators

Operator Category Description

%

Mathematical

Modulo division

*

Mathematical

Multiplication

+

Mathematical

Addition

+

String

Concatenation

+

List

Concatenation

-

Mathematical

Subtraction or unary minus

.

General

Property access

/

Mathematical

Division

<

Comparison

Less than

<=

Comparison

Less than or equal to

<>

Comparison

Inequality

=

Comparison

Equality

=~

String

Regular expression match

>

Comparison

Greater than

>=

Comparison

Greater than or equal to

AND

Boolean

Conjunction

CONTAINS

String comparison

Case-sensitive inclusion search

DISTINCT

General

Duplicate removal

ENDS WITH

String comparison

Case-sensitive suffix search

IN

List

List element existence check

IS NOT NULL

Comparison

Non-null check

IS NULL

Comparison

null check

NOT

Boolean

Negation

OR

Boolean

Disjunction

STARTS WITH

String comparison

Case-sensitive prefix search

XOR

Boolean

Exclusive disjunction

[]

General

Subscript (dynamic property access)

[]

List

Subscript (accessing element(s) in a list)

^

Mathematical

Exponentiation

3.9.3. Functions

Function Category Description

abs()

Numeric

Returns the absolute value of a number.

acos()

Trigonometric

Returns the arccosine of a number in radians.

all()

Predicate

Tests whether the predicate holds for all elements in a list.

any()

Predicate

Tests whether the predicate holds for at least one element in a list.

asin()

Trigonometric

Returns the arcsine of a number in radians.

atan()

Trigonometric

Returns the arctangent of a number in radians.

atan2()

Trigonometric

Returns the arctangent2 of a set of coordinates in radians.

avg()

Aggregating

Returns the average of a set of values.

ceil()

Numeric

Returns the smallest floating point number that is greater than or equal to a number and equal to a mathematical integer.

coalesce()

Scalar

Returns the first non-null value in a list of expressions.

collect()

Aggregating

Returns a list containing the values returned by an expression.

cos()

Trigonometric

Returns the cosine of a number.

cot()

Trigonometric

Returns the cotangent of a number.

count()

Aggregating

Returns the number of values or rows.

degrees()

Trigonometric

Converts radians to degrees.

distance()

Spatial

Returns a floating point number representing the geodesic distance between any two points in the same CRS.

e()

Logarithmic

Returns the base of the natural logarithm, e.

endNode()

Scalar

Returns the end node of a relationship.

exists()

Predicate

Returns true if a match for the pattern exists in the graph, or if the specified property exists in the node, relationship or map.

exp()

Logarithmic

Returns e^n, where e is the base of the natural logarithm, and n is the value of the argument expression.

extract()

List

Returns a list lresult containing the values resulting from an expression which has been applied to each element in a list list.

filter()

List

Returns a list lresult containing all the elements from a list list that comply with a predicate.

floor()

Numeric

Returns the largest floating point number that is less than or equal to a number and equal to a mathematical integer.

haversin()

Trigonometric

Returns half the versine of a number.

head()

Scalar

Returns the first element in a list.

id()

Scalar

Returns the id of a relationship or node.

keys()

List

Returns a list containing the string representations for all the property names of a node, relationship, or map.

labels()

List

Returns a list containing the string representations for all the labels of a node.

last()

Scalar

Returns the last element in a list.

left()

String

Returns a string containing the specified number of leftmost characters of the original string.

length()

Scalar

Returns the length of a path.

log()

Logarithmic

Returns the natural logarithm of a number.

log10()

Logarithmic

Returns the common logarithm (base 10) of a number.

lTrim()

String

Returns the original string with leading whitespace removed.

max()

Aggregating

Returns the maximum value in a set of values.

min()

Aggregating

Returns the minimum value in a set of values.

nodes()

List

Returns a list containing all the nodes in a path.

none()

Predicate

Returns true if the predicate holds for no element in a list.

percentileCont()

Aggregating

Returns the percentile of the given value over a group using linear interpolation.

percentileDisc()

Aggregating

Returns the nearest value to the given percentile over a group using a rounding method.

pi()

Trigonometric

Returns the mathematical constant pi.

point() - cartesian 2D

Spatial

Returns a point object, given two coordinate values in the cartesian coordinate system.

point() - WGS 84

Spatial

Returns a point object, given two coordinate values in the WGS 84 coordinate system.

properties()

Scalar

Returns a map containing all the properties of a node or relationship.

radians()

Trigonometric

Converts degrees to radians.

rand()

Numeric

Returns a random floating point number in the range from 0 (inclusive) to 1 (exclusive); i.e. [0, 1).

range()

List

Returns a list comprising all integer values within a specified range.

reduce()

List

Runs an expression against individual elements of a list, storing the result of the expression in an accumulator.

relationships()

List

Returns a list containing all the relationships in a path.

replace()

String

Returns a string in which all occurrences of a specified string in the original string have been replaced by another (specified) string.

reverse()

List

Returns a list in which the order of all elements in the original list have been reversed.

reverse()

String

Returns a string in which the order of all characters in the original string have been reversed.

right()

String

Returns a string containing the specified number of rightmost characters of the original string.

round()

Numeric

Returns the value of a number rounded to the nearest integer.

rTrim()

String

Returns the original string with trailing whitespace removed.

sign()

Numeric

Returns the signum of a number: 0 if the number is 0, -1 for any negative number, and 1 for any positive number.

sin()

Trigonometric

Returns the sine of a number.

single()

Predicate

Returns true if the predicate holds for exactly one of the elements in a list.

size()

Scalar

Returns the number of items in a list.

size() applied to pattern expression

Scalar

Returns the number of sub-graphs matching the pattern expression.

size() applied to string

Scalar

Returns the size of a string.

split()

String

Returns a list of strings resulting from the splitting of the original string around matches of the given delimiter.

sqrt()

Logarithmic

Returns the square root of a number.

startNode()

Scalar

Returns the start node of a relationship.

stDev()

Aggregating

Returns the standard deviation for the given value over a group for a sample of a population.

stDevP()

Aggregating

Returns the standard deviation for the given value over a group for an entire population.

substring()

String

Returns a substring of the original string, beginning with a 0-based index start and length.

sum()

Aggregating

Returns the sum of a set of numeric values.

tail()

List

Returns all but the first element in a list.

tan()

Trigonometric

Returns the tangent of a number.

timestamp()

Scalar

Returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

toBoolean()

Scalar

Converts a string value to a boolean value.

toFloat()

Scalar

Converts an integer or string value to a floating point number.

toInteger()

Scalar

Converts a floating point or string value to an integer value.

toLower()

String

Returns the original string in lowercase.

toString()

String

Converts an integer, float or boolean value to a string.

toUpper()

String

Returns the original string in uppercase.

trim()

String

Returns the original string with leading and trailing whitespace removed.

type()

Scalar

Returns the string representation of the relationship type.

3.9.4. Expressions

Name Description

CASE Expression

A generic conditional expression, similar to if/else statements available in other languages.

3.9.5. Cypher query options

Name Type Description

CYPHER $version query

Version

This will force 'query' to use Neo4j Cypher $version. The default is 3.3.

CYPHER planner=rule query

Planner

This will force 'query' to use the rule planner. As the rule planner was removed in 3.2, doing this will cause 'query' to fall back to using Cypher 3.1.

CYPHER planner=cost query

Planner

Neo4j 3.3 uses the cost planner for all queries.

CYPHER runtime=interpreted query

Runtime

This will force the query execution engine to use the interpreted runtime. This is the only option in Neo4j Community Edition.

CYPHER runtime=slotted query

Runtime

This will cause the query execution engine to use the slotted runtime if it supports 'query'. This is only available in Neo4j Enterprise Edition.

CYPHER runtime=compiled query

Runtime

This will cause the query execution engine to use the compiled runtime if it supports 'query'. This is only available in Neo4j Enterprise Edition.