Guide
HelixDB accepts Cypher statements alongside its native operation-tree queries.
Both languages run against the same graph, transactions, and indexes, so data
written with one is visible to the other, and existing databases need no
migration.
Cypher support is a profile of openCypher, not full compatibility. The clauses,
expressions, and functions listed under What is supported run.
Everything in What is not supported is rejected with a
specific error before the statement reads or writes anything.
Cypher as described here is served by local servers running the
ghcr.io/helixdb/helixdb:v0.0.13 image or later, and by Helix Cloud gateways.
The SDK examples below need TypeScript 4.0.0, Python 0.4.0, Rust 4.0.0 or Go v0.4.0.
TypeScript 3.2.0, Python 0.3.4, Rust 3.0.0 and Go v0.3.1 do not include the Cypher methods;
with those releases, use the HTTP API to run and explain statements.
Run a statement
Send one statement, with optional parameters and a query name, toPOST /v2/cypher. The server works out whether the statement reads or writes.
columns and rectangular rows, with one
value per column in column order:
query is required; parameters and query_name are optional. Duplicate rows
are kept unless the statement uses DISTINCT, and row order is only defined by
ORDER BY. A write without RETURN succeeds with empty columns and rows.
Parameters hold values. Labels, relationship types, and variable names are part
of the statement, so keep values in parameters instead of building them into the
query text.
Over HTTP
A local server has no authentication:POST /v2/query,
with the cluster API key and, on a GA shared gateway, the database ID:
403 for a statement that writes. The
HTTP API reference describes
the headers, status codes, and lossless value encoding in full.
From the CLI
From a linked local project,helix cypher runs a statement against the local
instance:
Request options
The native request options apply to Cypher too:
Writes wait for durability by default. Skipping the wait returns once the write is applied
on the writer, so a crash before its WAL upload loses it. See
execution headers for how
local servers and Helix Cloud handle each option.
Rust and TypeScript set options on
request_builder() / requestBuilder() before
.cypher(...); Go and Python pass them to Cypher and cypher. A warm-only read
that Helix Cloud answers with 204 No Content returns no rows. Embedded clients
reject request options.
Explain a statement
POST /v2/cypher/explain takes the same body and plans the statement without
running it, so explaining a write changes nothing. The plan reports the
statement’s effect (Read or Write), its bindings, the selected access paths
such as index lookups, estimated cardinalities, blocking work, Cartesian
products, and optimizer warnings. Planning checks parameters, so supply every
parameter the statement uses.
What is supported
Create and read a small graph:
WHERE of a WITH filters the rows that clause returns, after its
DISTINCT, ORDER BY, SKIP, and LIMIT: WITH x ORDER BY x LIMIT 3 WHERE x > 2
keeps at most the third row. After SKIP or LIMIT, only the variables the
WITH projects remain in scope.
value =~ pattern is true when the regular expression matches the whole
string, as in openCypher, and null when either side is null or not a string.
Patterns use the Rust regex syntax of the native grep step and matches
predicate: linear time, no look-around or backreferences, and Unicode-aware.
(?i) ignores case and (?s) lets . match a newline. A Cypher string
writes one backslash as \\, so 'NCT\\d{8}' is the pattern NCT\d{8}. A
pattern that is not a valid regular expression, or is longer than 4 KiB, is a
syntax_error with detail invalid_regex when it is a literal or a string
parameter, directly, as a map parameter’s property, or through a variable
projected from either (WITH $p AS p, WITH '(' AS p).
The statement fails before any row is read, so the error does not depend on
the data. A pattern computed from other values, such as $p + '' or a
property, is checked when a row evaluates it, and an invalid one fails with
argument_error and invalid_regex.
What is not supported
These constructs are valid openCypher but outside the profile. Each is rejected before anything runs, with the error categoryunsupported_feature and the
details.detail code shown, unless the table says otherwise.
Instead of
MERGE, upsert with a unique index. Instead of
FOREACH, UNWIND a list parameter.
Some of these fail as ordinary compile errors instead:
CREATE INDEX ...is asyntax_error(unexpected_syntax). Create indexes with the native secondary, vector, and text index APIs; Cypher planning then uses compatible indexes automatically.- A relationship in
CREATEneeds exactly one type and a direction, otherwise the statement is asyntax_error(no_single_relationship_type). - A parameter map in a
MATCHpattern, such asMATCH (n:User $props), is asyntax_error(invalid_parameter_use). Write the properties as a map literal, such as{email: $email}. - An unrecognized function name is a
syntax_error(unknown_function). That includeselementId(); useid(). - A statement that is also invalid openCypher reports the standard error, such as
variable_already_boundfor aCREATEthat redeclares a variable.
Values and parameters
Nulls, booleans, strings, lists, maps, and finite floats use ordinary JSON values, in parameters and in results. Integers inside JavaScript’s safe range use JSON numbers. Larger integers and non-finite floats use tagged values:
Node and relationship IDs are unsigned decimal strings in separate namespaces;
keep them as strings.
id() reports an overflow when an ID does not fit a signed
64-bit integer. Relationship endpoints keep their stored direction even when a
path traverses them in reverse. Internal metadata is left out of property maps.
Scalars, lists, and maps, including their tagged forms, can be passed as
parameters; nodes, relationships, and paths cannot.
The SDKs keep tagged values in results. TypeScript also accepts bigint
parameters and sends them tagged.
A datetime result is plain text, so it reads the same as a string holding that
text. A typed date_time parameter of an in-process request binds as a
datetime; JSON parameters have no datetime form, so read datetime text with
datetime($at), which still uses indexes.
Writes and transactions
Each statement that writes runs in one transaction, including its index changes. If any clause fails, nothing the statement wrote is kept.- A created node needs exactly one non-empty label, and a created relationship
exactly one non-empty type.
MATCHwithout a label scans all nodes. - Stored properties are scalars or lists of one scalar type. Maps and nested lists can be used in expressions but not stored, so storing one fails the statement.
SET n += {...}updates the given keys and keeps the rest.SET n = {...}replaces every user property. Setting a property tonullremoves it.SETitems run in order, so later items see earlier changes.- A plain
DELETEof a node that still has relationships fails the statement.DETACH DELETEremoves the relationships and the node. - Index rules still apply: a value an index cannot store fails the statement, including a string too large for an index key (about 64 KiB).
- Do not retry a write automatically when its commit outcome is uncertain; see error handling.
Upsert without MERGE
To create a node, or update it if it exists, let a unique index decide:-
Create a unique equality index on the key property, such as
emailonUser. -
Send the
CREATE: -
On
409 unique_constraint_violation, the node exists and nothing was written. Update it instead: - If the update returns no rows, the node was deleted in between; go back to step 2.
CREATEs, or reading first and creating when nothing
matched, add duplicates. An UNWIND batch fails as a
whole on its first duplicate, so to upsert a batch, MATCH its keys first, CREATE the
missing rows, and update the rest; the index still rejects a row another client created
meanwhile.
Functions, aggregation, and grouping
toInteger()andtoInt()convert decimal strings exactly, including scientific notation, and truncate fractions toward zero:toInteger('9007199254740993.0')returns9007199254740993. Invalid text and values outside the signed 64-bit range return null.avg()ignores nulls, returns null for an empty group, and returns a float. A large total does not overflow while the inputs are finite.sum()reports integer overflow.- Expressions in
RETURNorWITHwithout aggregates define the groups. In an expression that mixes aggregation with other operations, everything outside the aggregate’s arguments must be a constant, a parameter, a grouped variable, or a projected property, following the openCypher grouping rules. An ambiguous aggregation is rejected before anything runs. ORDER BYcan use an aggregate without returning it, as inRETURN 1 + sum(amount) AS total ORDER BY 2 - sum(amount).- A simple
CASE value WHEN ...evaluatesvalueonce, andnullnever matchesnull; test for a missing value withCASE WHEN value IS NULL THEN .... Only the selected branch is evaluated, but aggregate arguments insideCASEare always evaluated.
Datetimes
A datetime is a UTC instant with millisecond precision, the same value native queries store from datetime literals,now(), and typed date_time
parameters. Cypher reads those stored properties, at any depth in lists and
maps, and CREATE and SET store datetimes back as datetimes. A list of
datetimes, however it is written, is stored as one datetime list, which an
equality index holds and an equality such as
e.slots = [datetime('2026-06-01'), datetime('2026-06-02')] reads through it.
datetime()andtimestamp()read the statement’s clock, once, before the statement is planned: every call in one statement, in a filter, a result or a write, returns the same instant, as a datetime or as integer epoch milliseconds. There is noduration; subtract milliseconds instead, as indatetime({epochMillis: timestamp() - 86400000})for a day ago.datetime(text)reads RFC 3339 (2026-06-01T09:00:00Z) with aZor±hh:mmoffset, a date and time without an offset (read as UTC), or a date alone (2026-06-01, UTC midnight). Every field is zero-padded, years run from0000to9999, in the text and in UTC once its offset applies, so9999-12-31T23:59:59-00:01is rejected, and seconds are required. A space may separate date and time; digits past milliseconds are dropped.datetime({epochMillis: n})converts an integer, and a datetime or null passes through.datetimeOrNull(x)isdatetime(x), except that a value it cannot read is null instead of an error, astoIntegerOrNulland the other…OrNullconversions are for theirs.requireDatetime(x)returns a datetime or null unchanged and fails withtype_errorfor anything else.- Datetimes compare in time order. Against any type other than text,
=is false and<,>,<=,>=are null, as for a string against a number. Against text, every comparison,IN,CASEmatch, andSTARTS WITH,ENDS WITH, orCONTAINSis null, so it never matches; see below.ORDER BYplaces datetimes after paths and before strings.min,max,DISTINCT, and grouping work on datetimes;sum,avg, and arithmetic reject them. - Fields read UTC components as integers:
dt.year,dt.quarter,dt.month,dt.weekanddt.weekYear(ISO 8601 weeks, starting Monday),dt.day,dt.ordinalDay,dt.dayOfWeek(Monday is 1),dt.hour,dt.minute,dt.second,dt.millisecond,dt.epochSeconds, anddt.epochMillis. Use them to bucket or compute, such asb.at.epochMillis - a.at.epochMillisfor a duration in milliseconds. Any other field is atype_error. toString(dt)returns the same RFC 3339 text a result shows.
2026-6-1, is rejected before anything runs (unsupported_feature,
function). Literal text in the grammar’s form that names no instant, such
as 2026-02-30 or a leap second, is rejected before anything runs with
argument_error (invalid_datetime). Text that arrives at run time and does
not read fails with argument_error (invalid_datetime). A stored instant
outside years 0000–9999 compares and sorts, and a result renders it as
native responses do (+10000-01-01T00:00:00.000Z), but datetime() does
not read that text back; use datetime({epochMillis: n}). Past about
262,000 years from year 0, returning it, converting it to text, or reading a
calendar field fails with argument_error (datetime_out_of_range), as a
native response does.
Text is never read as a datetime, so a datetime compared with text is null,
as a comparison with null is, and never matches. A filter such as
e.at > '2026-01-01', e.at = '2026-01-01T00:00:00Z', or e.at >= $since
with a string parameter matches no node whose at is a datetime, and nor
does e.at <> '…' or NOT e.at = '…'; read the text first with
datetime('2026-01-01') or datetime($since), or compare toString(e.at)
as text. The same holds at any depth inside lists and maps, for pattern
properties such as {at: '…'}, and for joins and lookups that compare two
stored values. Indexes never change the result: a scan, an equality or range
index on the property, and an index on another property in the same WHERE
all return the same rows.
When both types are known before the query runs, it fails instead, with
type_error (datetime_text_comparison). This applies to a comparison or
text match (datetime() > '2026-01-01'), an IN member
(datetime() IN ['2026-01-01']), and a simple CASE value against its
subject (CASE datetime() WHEN '2026-01-01' THEN …). A parameter’s type is
known from its bound value when the parameter is compared directly
($at = '…'), through a property of a map parameter ($obj.at), or through a
variable set from either (WITH $at AS a). Each member of a list parameter is
checked the same way, so datetime() IN $texts fails too. A written-out list or
CASE that mixes datetimes and text fails even when an earlier member matches.
Any other operand built from a
parameter, such as UNWIND $dates AS d or coalesce($at, …), runs and
compares as null.
The store has no schema, so a SET of text, such as
SET e.at = '2026-06-01T00:00:00Z', stores text even where the property
otherwise holds datetimes. Comparisons over such a mixed property follow the
same rule: a datetime matches only datetimes and text only text. Write
SET e.at = datetime('…') to keep the property one type.
Indexes and performance
Cypher plans use existing native indexes automatically. You do not name an index in the statement; explain shows which one was chosen.- An equality on a labeled node, such as
MATCH (u:User {email: $email})orWHERE u.email = $email, can read an equality index. So canINlists of up to 64 values andORed equalities on one property. - A range such as
WHERE u.age >= 21 AND u.age < $maxcan read a range index, and stops reading as soon as aLIMITis satisfied. ORDER BYon a range-indexed property in the index’s direction, with a range bound and aLIMIT, reads the index in order instead of sorting.id(n) = $idandid(n) IN [7, 9, 12](a literal list) read those nodes directly; a list parameter does not. See fetch many nodes.- An equality against an earlier variable, as in
UNWIND $ids AS k MATCH (u:User {uid: k}), looks up the index once per row. - An expansion only reads the relationship types it names, so
-[:WROTE|LIVES_IN]->skips a node’s other relationships. LIMITstops scans and expansions early when the clauses before it cannot fail. Reading a stored property inRETURNcan fail, so return whole nodes, or applyWITH ... LIMITfirst and read properties afterwards:MATCH (u:User) WITH u LIMIT 10 RETURN u.name.
AND, OR,
XOR, and NOT combinations over literals, parameters, variables, and properties
qualify, as do datetime literals, typed datetime parameters, datetime($text)
of a parameter that reads as a datetime, and the statement clock: datetime(),
timestamp(), integer arithmetic over them, literals and parameters, and
datetime({epochMillis: n}) of such an integer, so a recency filter such as
WHERE e.at > datetime({epochMillis: timestamp() - $windowMs}) reads a range
index. Arithmetic that would fail, such as an overflow, and other function calls
keep the label scan, which raises the error.
Load and fetch in batches
Send many rows as one list parameter andUNWIND it. A request is one transaction,
so each batch is written entirely or not at all:
index_operation_batch_too_large). A few thousand small rows per
request stays well inside them. Parallel batches can conflict; resend a 409 with
retryable: true unchanged.
Fetch many nodes
Only a literal list of IDs reads nodes directly. A list parameter (id(n) IN $ids)
or an ID from a variable (UNWIND $ids AS i MATCH (n) WHERE id(n) = i) scans the
label, or every node when the pattern has no label. Write the IDs into the statement:
UNWIND the keys; each row is one index lookup, at
any list length:
WHERE u.email IN $emails reads the index too, but only for up to 64 values; a
longer list scans the label.
Limits
AND, OR, and XOR chains count as one nesting level at any length; every other
operator adds one, so a + b + c + ... fails at about 48 terms. Compute such values in
the application and pass them as parameters.
A statement that exceeds a budget fails with resource_limit (HTTP 429)
instead of returning a truncated result, and a write that fails this way commits
nothing. Reduce the work rather than retrying; see
HTTP 429.
UNWIND range(...) streams its values, while range() in an expression builds the
whole list first.
Errors
A failed statement returns the Cypher error body:error is the category and details.detail the specific condition, both in
lower snake case. phase is compile (nothing ran) or runtime, and span
gives the byte range of the statement text that failed, when known. Request,
authentication, storage, and transaction failures use the native error envelope.
The error reference
lists every category with its HTTP status and retry guidance.
Next steps
HTTP API
Request headers, status codes, and the OpenAPI contract for the Cypher routes.
Error handling
Cypher error categories, HTTP statuses, and when to retry.
Reading data
The native read API, with Cypher equivalents.
Secondary indexes
Create the indexes that Cypher plans read.