Skip to content

Query Language

A read-only subset of Cypher.

MATCH pattern [, pattern ...] [MATCH ...]
[WHERE condition]
RETURN [DISTINCT] item [AS name] [, ...]
[ORDER BY item [ASC | DESC] [, ...]]
[SKIP n] [LIMIT n]

Keywords are case-insensitive. Labels, types and property names are case-sensitive. A query can be up to 16 KiB.

Patterns

Pattern Matches
(n) Any node
(n:Agent:Bot) Nodes with both labels
(n:Agent {name: 'Ann'}) Nodes with the property
(a)-[r:FOLLOWS]->(b) Outgoing edges of one type
(a)<-[r:FOLLOWS]-(b) Incoming edges
(a)-[r:FOLLOWS\|MEMBER]-(b) Either direction, either type
(a)-->(b), (a)--(b) Any type
(a)-[r {since: 2025}]->(b) Edges with the property
(a)-[p:FOLLOWS*2]->(b) Exactly 2 edges
(a)-[p:FOLLOWS*1..3]->(b) 1 to 3 edges
(a)-[p:FOLLOWS*..3]->(b) 1 to 3 edges
(a)-[p:FOLLOWS*]->(b) 1 to 8 edges
(a)-[p:FOLLOWS*0..1]->(b) The node itself, or 1 edge
  • A path can have at most 16 edges per variable-length segment.
  • An edge is used at most once per result row, across all patterns of the query.
  • A node variable used twice must match the same node. An edge variable can be bound once.
  • A variable on a variable-length segment is a list of edges.

Conditions

Form Meaning
=, <>, <, <=, >, >= Comparison. Ordering applies to two numbers or two strings
AND, OR, NOT, parentheses Logic
x IN [1, 2], x IN n.tags Membership
n.tags CONTAINS 'x' Membership if the left side is a list
n.name CONTAINS 'x', STARTS WITH, ENDS WITH Text
n.age IS NULL, IS NOT NULL Whether a property is set
$name A parameter

A missing property is null. Comparing with null gives null, and only rows whose condition is true are kept. NOT null is null.

Literals are strings in single or double quotes (with \n, \t, \\, \' and \"), numbers, true, false, null and lists.

Functions

Function Applies to Result
id(n) node Its id
labels(n) node List of labels
type(r) edge Its type
length(p) variable-length segment Number of edges

Aggregation

count(*), count(x), collect(x), sum(x), min(x), max(x) and avg(x). count(DISTINCT x) and the same for the others ignore repeats. Null values are skipped. The columns of RETURN that are not aggregates form the groups:

MATCH (a:Agent)-[:MEMBER]->(t:Team)
RETURN t.name, count(a) AS members, collect(a.name) AS names
ORDER BY members DESC

An aggregate must be a whole column. With no matches, a query that returns only aggregates gives one row.

Ordering

ORDER BY takes a column name, the exact text of a column, or, when the query neither aggregates nor uses DISTINCT, any expression. Ascending order places strings before booleans, booleans before numbers, and null last.

Results

columns are the names, rows the values, and truncated says whether more rows existed beyond LIMIT or the service limit. A returned node is {id, labels, props, sources} and a returned edge is {type, from, to, key, props, sources}.

Limits

Limit Default When exceeded
Steps (nodes scanned and edges followed) 5,000,000 Error 422
Rows or groups held 10,000 Error 422. Queries without ORDER BY, SKIP or aggregation are truncated instead
Time 10 seconds Error 422

There is no OPTIONAL MATCH, WITH, UNWIND, subquery or write clause.