TETHESIS
DOCUMENTATION · CYPHER

Cypher reference

InvariantDB speaks openCypher, with bitemporal extensions. This is the shape of the common reads, writes, time-travel queries and procedure calls — the full covered surface is in the docs, and the part that isn’t covered is listed there too.

READING

Match, filter, return

MATCH (p:Person)-[:KNOWS]->(f:Person) WHERE p.name = $name AND f.age > 21 RETURN f.name, f.age ORDER BY f.age DESC LIMIT 10;

Supports WITH for multi-stage pipelines, OPTIONAL MATCH, predicates (=, <>, STARTS WITH, CONTAINS, =~ regex, IN), quantifiers (ANY/ALL/NONE/SINGLE), and shortestPath / allShortestPaths.

WRITING

Create, merge, set, delete

CREATE (p:Person {id: "p1", name: "Alice"}); // MERGE = match-or-create (needs an index on the matched key) MERGE (p:Person {id: "p1"}) ON CREATE SET p.created = timestamp(); MATCH (p:Person {id: "p1"}) SET p += {city: "NYC"}, p:Active; // map-merge + add a label MATCH (p:Person {id: "p1"}) DETACH DELETE p; // drops relationships first

Plain DELETE refuses a node that still has relationships; DETACH DELETE removes them first. Deletes are bitemporal — the record ends as of now, and its past versions stay in history.

BITEMPORAL

The two clocks, in the query

Every property carries a valid time (true in the world) and a recorded time (known to the engine). Add a time clause to a read and every top-level match rewinds to that moment.

// what was true on 1 Jan MATCH (p:Person) AT VALID '2026-01-01' RETURN p; // what we KNEW on 15 Jan about how things stood on 31 Dec MATCH (p:Person) AT VALID '2025-12-31' AT RECORDED '2026-01-15' RETURN p; // one row per version overlapping a window MATCH (p:Person) OVER VALID BETWEEN '2025-01-01' AND '2026-01-01' RETURN p.id, p.email, p.valid_from, p.valid_to; // why did this answer change? EXPLAIN CHANGE MATCH (p:Person {id: "42"}) RETURN p.address;

Procedures complement the inline syntax: db.history(id), db.propertyHistory(id, 'prop'), db.changes(label, prop, from, to), db.delta(seqA, seqB), db.changeRate(label, windowSecs). A past read is answered completely or refused — never silently partial.

AGGREGATION & LISTS

Group, collect, comprehend

MATCH (p:Person)-[:OWNS]->(c:Car) WITH p, count(c) AS cars WHERE cars > 1 RETURN p.name, cars, collect(c.model) AS models; // list + pattern comprehensions, map projection, reduce, CASE RETURN [(p:Person)-[:OWNS]->(c:Car) WHERE c.year > 2020 | c.model];
PROCEDURES

One rule for every CALL

Every procedure — db.*, gds.*, any namespace — is invoked the same way. There is no special-casing.

CALL [namespace.]proc(arg1, arg2, …) [YIELD col1 [AS alias1], …]

Three gotchas account for almost every “procedure won’t run”:

1Missing CALL

Without the leading CALL, gds.vectorSearch(…) parses as a property access and chokes. Always lead with CALL.

2A bare procedure in RETURN/WITH

Procedures are clause-level, not expressions. Drive the projection from the CALL’s yielded columns, not RETURN gds.vectorSearch(…).

3YIELD with no RETURN

It parses and runs, but the response has zero columns — add a RETURN so the yielded columns reach the client. (A bare CALL with no YIELD is fine for void procedures.)

SEARCH, INDEXES & PLANS

Vectors, text, and what the planner did

// vector + full-text + inline similarity CALL gds.vectorSearch('Memo', 'embedding', $vec, 10) YIELD nodeId, score RETURN nodeId, score; MATCH (d:Doc) RETURN d ORDER BY cosine(d.embedding, $vec) DESC LIMIT 10; CREATE INDEX FOR (p:Person) ON (p.id); EXPLAIN MATCH (p:Person {id: "p1"}) RETURN p; // row estimates + why an index isn't used

EXPLAIN ANALYZE adds real timing. Indexes back point lookups and MERGE keys; without one, a keyed match degrades to a label scan.

ERRORS

Structured, with a subcode

Errors come back as a structured envelope with a stable code and a specific subcode, so a client branches on the subcode rather than parsing a message — e.g. CONDITION_FAILED, READ_SET_CHANGED, TEMPORAL_READ_LIMIT, FULLTEXT_INDEX_NOT_FOUND. Each says whether a retry can help.

Query on your own data