Skip to content

CypherService

OpenCypher-compatible query execution service.

Proto source

query/cypher.proto

Transport

All methods are available via:

  • gRPC on port 7080 — native high-performance API
  • REST/JSON on port 7081 — HTTP/JSON transcoding via embedded structured-proxy

Query Parameters (REST)

Named parameters are passed in the parameters map. Each value is a JSON object with a single key matching the PropertyValue proto field name:

json
{
  "query": "MATCH (n:Concept {name: $name}) RETURN n",
  "parameters": {
    "name":            { "stringValue": "machine learning" },
    "limit":           { "intValue": "10" },
    "threshold":       { "floatValue": 0.4 },
    "active":          { "boolValue": true },
    "question_vector": { "vectorValue": { "values": [0.1, 0.2, 0.3] } },
    "tags":            { "listValue": { "values": [{"stringValue": "ml"}, {"stringValue": "ai"}] } }
  }
}

Available parameter types:

JSON keyProto fieldExample
stringValuestring{ "stringValue": "alice" }
intValueint64{ "intValue": "42" }
floatValuedouble{ "floatValue": 0.95 }
boolValuebool{ "boolValue": true }
vectorValueVector{ "vectorValue": { "values": [0.1, 0.2] } }
listValuePropertyList{ "listValue": { "values": [...] } }
bytesValuebytes{ "bytesValue": "<base64>" }

Vector parameters: use vectorValue, not listValue. vectorValue maps to the dedicated Vector proto type and enables vector index pushdown in the query planner.

Methods

ExecuteCypher

Execute an OpenCypher query and return results.

HTTP: POST /v1/query/cypher

Request: ExecuteCypherRequest

FieldTypeDescription
querystringOpenCypher query string.
parametersmap<string, PropertyValue>Named query parameters bound at execution time.
read_preferenceReadPreferenceWhich cluster node may serve this read. UNSPECIFIED defaults to PRIMARY (leader-only reads). Use SECONDARY_PREFERRED for read scale-out in 3-node CE cluster.
read_concernReadConcernData consistency guarantee for this read. UNSPECIFIED defaults to LOCAL (return whatever this node has applied). Use MAJORITY for reads that must not see rolled-back data. Use LINEARIZABLE for strictest freshness (leader only, adds ~1 RTT).
write_concernWriteConcernDurability guarantee for write statements (CREATE / MERGE / SET / DELETE). UNSPECIFIED / omitted defaults to W1 (leader-acknowledged, not replicated). Use MAJORITY for production writes that must survive a single node failure. Causal sessions (read_concern.after_index > 0) require write_concern.level >= MAJORITY. The server rejects writes with lower durability in causal sessions because a non-majority write may never be replicated: if the leader crashes before drain, the returned applied_index becomes a dangling causal dependency that can never be satisfied by a follower read. Read-only queries ignore this field.

Response: ExecuteCypherResponse

FieldTypeDescription
columnsstring[]
rowsRow[]
statsQueryStats

ExplainCypher

Explain an OpenCypher query plan without executing.

HTTP: POST /v1/query/cypher/explain

Request: ExplainCypherRequest

FieldTypeDescription
querystring
parametersmap<string, PropertyValue>

Response: ExplainCypherResponse

FieldTypeDescription
planQueryPlan

Types

ExecuteCypherRequest

FieldTypeDescription
querystringOpenCypher query string.
parametersmap<string, PropertyValue>Named query parameters bound at execution time.
read_preferenceReadPreferenceWhich cluster node may serve this read. UNSPECIFIED defaults to PRIMARY (leader-only reads). Use SECONDARY_PREFERRED for read scale-out in 3-node CE cluster.
read_concernReadConcernData consistency guarantee for this read. UNSPECIFIED defaults to LOCAL (return whatever this node has applied). Use MAJORITY for reads that must not see rolled-back data. Use LINEARIZABLE for strictest freshness (leader only, adds ~1 RTT).
write_concernWriteConcernDurability guarantee for write statements (CREATE / MERGE / SET / DELETE). UNSPECIFIED / omitted defaults to W1 (leader-acknowledged, not replicated). Use MAJORITY for production writes that must survive a single node failure. Causal sessions (read_concern.after_index > 0) require write_concern.level >= MAJORITY. The server rejects writes with lower durability in causal sessions because a non-majority write may never be replicated: if the leader crashes before drain, the returned applied_index becomes a dangling causal dependency that can never be satisfied by a follower read. Read-only queries ignore this field.

ExecuteCypherResponse

FieldTypeDescription
columnsstring[]
rowsRow[]
statsQueryStats

ExplainCypherRequest

FieldTypeDescription
querystring
parametersmap<string, PropertyValue>

ExplainCypherResponse

FieldTypeDescription
planQueryPlan

QueryPlan

FieldTypeDescription
operatorstring
detailsmap<string, string>
childrenQueryPlan[]
estimated_rowsdouble

QueryStats

FieldTypeDescription
nodes_createdint64
nodes_deletedint64
edges_createdint64
edges_deletedint64
properties_setint64
execution_time_msint64
applied_indexuint64Raft log index applied on the serving node at query time. Clients use this as after_index in subsequent causal reads (R142). 0 means the node is not part of a Raft cluster (embedded mode).
served_by_leaderboolTrue when the read was served by the Raft leader. False for follower reads (read_preference = SECONDARY or NEAREST).

ReadConcern

Read concern configuration.

FieldTypeDescription
levelReadConcernLevelConsistency level for this read. UNSPECIFIED defaults to LOCAL.
after_indexuint64Causal fence: wait until the serving node has applied log entries up to at least this Raft log index before executing the read. Set to the QueryStats.applied_index value from a prior write response to guarantee read-your-writes: the read is guaranteed to observe all mutations up to and including that write. 0 = no fence (default). Only valid with level = MAJORITY or SNAPSHOT; returns FAILED_PRECONDITION if level = LOCAL or LINEARIZABLE. Has no effect in standalone (non-Raft) mode — all writes are immediately visible. The returned applied_index will always be 0 in standalone mode, so clients should not set after_index unless operating in cluster mode.
at_timestampuint64Snapshot pin: read the database as of this HLC timestamp (microseconds since Unix epoch, leader-assigned). Only valid with level = SNAPSHOT. Setting this with any other level returns FAILED_PRECONDITION. 0 = no pin (latest snapshot of the chosen level applies). Typical use: time-travel reads ("what did this query return at 2026-05-15 12:00:00?"). The timestamp must be within the MVCC retention window — older snapshots are GC'd. Reads beyond retention return UNAVAILABLE. Distinct from after_index: after_index is a fence (wait until at least this index is applied), at_timestamp is a pin (read exactly this version, no waiting).

Row

FieldTypeDescription
valuesPropertyValue[]

WriteConcern

Write concern configuration.

FieldTypeDescription
levelWriteConcernLevel
journalboolRequire WAL fsync before acknowledgement.
timeout_msuint32Timeout in milliseconds (0 = no timeout).

Enums

ReadConcernLevel

Read concern levels.

ValueNumberDescription
READ_CONCERN_LEVEL_UNSPECIFIED0
READ_CONCERN_LEVEL_LOCAL1Read from local replica (may be stale).
READ_CONCERN_LEVEL_MAJORITY2Read data committed by majority.
READ_CONCERN_LEVEL_LINEARIZABLE3Linearizable read (strongest guarantee).
READ_CONCERN_LEVEL_SNAPSHOT4Read from a consistent MVCC snapshot.

ReadPreference

Read preference for routing read operations.

ValueNumberDescription
READ_PREFERENCE_UNSPECIFIED0
READ_PREFERENCE_PRIMARY1
READ_PREFERENCE_PRIMARY_PREFERRED2
READ_PREFERENCE_SECONDARY3
READ_PREFERENCE_SECONDARY_PREFERRED4
READ_PREFERENCE_NEAREST5

WriteConcernLevel

Write concern levels. Write durability levels, ordered W0 < MEMORY < CACHE < W1 < MAJORITY. Selecting a level below W1 trades durability for latency: MEMORY and CACHE acknowledge the client before the write is replicated through Raft, with the drain thread batching them into proposals asynchronously. A leader crash before drain loses every in-flight MEMORY/CACHE write. Use only for telemetry, hot counters, session state — never for source-of-truth data.

ValueNumberDescription
WRITE_CONCERN_LEVEL_UNSPECIFIED0
WRITE_CONCERN_LEVEL_W01use only for non-critical metrics.
WRITE_CONCERN_LEVEL_W12mode and the lowest level safe to default for typical applications.
WRITE_CONCERN_LEVEL_MAJORITY3before Linearizable read concerns; safe under single-node failure.
WRITE_CONCERN_LEVEL_MEMORY4Lost on process crash before drain.
WRITE_CONCERN_LEVEL_CACHE5crash but not power failure before drain. Background drain to Raft.