Skip to main content

Cypher Clauses

Reference for supported Cypher clauses.

MATCH

Pattern matching clause.

Basic Node Pattern

MATCH (p:Person)

Typed Node Pattern

MATCH (p:Person:Student)

Node with Properties

MATCH (p:Person {name: 'Alice', age: 30})

Relationship Pattern

MATCH (a:Person)-[:KNOWS]->(b:Person)

Variable-Length Relationships

MATCH (a:Person)-[:KNOWS*1..3]->(b:Person)

WHERE

Filter clause with expressions.

Comparison Operators

MATCH (p:Person) WHERE p.age > 25
MATCH (p:Person) WHERE p.name = 'Alice'
MATCH (p:Person) WHERE p.age <> 30

String Operators

WHERE p.name CONTAINS 'John'
WHERE p.name STARTS WITH 'A'
WHERE p.name ENDS WITH 'n'

IN / NOT IN

WHERE p.city IN ['NYC', 'LA', 'SF']
WHERE p.status NOT IN ['archived', 'deleted']

NULL Checks

WHERE p.email IS NULL
WHERE p.email IS NOT NULL

Logical Operators

WHERE p.age > 25 AND p.status = 'active'
WHERE p.city = 'NYC' OR p.city = 'LA'
WHERE NOT p.archived
WHERE (p.age > 18 AND p.city = 'NYC')

RETURN

Specify return columns.

Basic Return

MATCH (p:Person) RETURN p.name, p.age

DISTINCT

MATCH (p:Person) RETURN DISTINCT p.city

Aliases with AS

MATCH (p:Person) RETURN p.name AS fullName, p.age AS years

ORDER BY

Sort results.

Ascending (Default)

RETURN p.name ORDER BY p.age

Descending

RETURN p.name ORDER BY p.age DESC

Multiple Columns

RETURN p.city, p.name ORDER BY p.city, p.name DESC

SKIP / LIMIT

Pagination.

Skip Rows

MATCH (p:Person) RETURN p.name ORDER BY p.age SKIP 10

Limit Results

MATCH (p:Person) RETURN p.name LIMIT 10

Combined Pagination

MATCH (p:Person)
RETURN p.name
ORDER BY p.age
SKIP 0
LIMIT 10

With Parameters

MATCH (p:Person) RETURN p.name LIMIT $limit

Aggregation with GROUP BY

Group and aggregate results.

Basic Aggregation

MATCH (p:Person) RETURN p.city, COUNT(*) AS count

Multiple Aggregates

MATCH (p:Person)
RETURN p.city, MIN(p.age), MAX(p.age), AVG(p.age)

HAVING Clause

MATCH (p:Person)
RETURN p.city, COUNT(*) AS cnt
HAVING cnt > 1

Named Paths

Capture traversal paths as variables.

MATCH p = (a:Person)-[:KNOWS]->(b:Person)-[:KNOWS]->(c:Person) RETURN p

Unsupported Clauses

The following clauses are rejected by the read-only Cypher engine:

ClauseReason
CREATEWrite operations not supported
DELETEWrite operations not supported
SETWrite operations not supported
REMOVEWrite operations not supported
MERGEWrite operations not supported
WITHComplex queries not supported
UNWINDComplex queries not supported