Skip to content

SQL & Wire Format Reference ​

Operators ​

OperatorUsageDescription
@@@WHERE body @@@ 'query'Filters rows matching the full-text query.
<=>ORDER BY body <=> 'query'Ranks matching rows by BM25 relevance.

Functions ​

FunctionSignatureDescription
index_ctids_hybrid(index regclass, tenant text, query_json text, query_vec bytea, k int, pool int, rrf_k int, lex_weight real, vec_weight real)Single-scan lexical + vector RRF returning (ctid, score, lex_rank, vec_rank).
snippet_doc(body text, query text, max_chars int)Returns a highlighted excerpt around matching query terms.
facet_counts(index regclass, tenant text, query_json text, field text)Returns grant-safe facet counts for matching rows.
diagnose_query(index regclass, tenant text, query_json text)Identifies zero-hit terms without leaking hidden rows.
search_batch(index regclass, tenant text, queries_json text)Runs multiple queries in one consistent snapshot.
verify(index regclass)Verifies every visible heap row is indexed (returns 0 rows when clean).
spill(index regclass)Flushes buffered writes into an immutable segment.
merge(index regclass)Compacts segments online.

Query JSON fields ​

FieldTypeDescription
qstringFull-text query string.
grantsstring[]Caller's authorized permission tokens.
valid_atstringISO-8601 date/timestamp for point-in-time filtering.
phrasesstring[]Exact phrases that must appear in order.
max_per_groupintegerMaximum rows returned per document group (e.g. 1 for latest version only).

Binary vector format (bytea) ​

If you encode query or document vectors directly without piramidedb-agentic, pack an 8-byte little-endian header followed by dims signed 8-bit integers:

OffsetSizeTypeValue
02uint16Number of dimensions (1..=4096)
21uint8Quantization type (1 = per-vector max-abs int8)
31uint8Reserved (0)
44float32scale = max_abs(vec) / 127.0 (0.0 for zero vector)
8dimsint8[dims]round(v[i] / scale) clamped to [-127, 127]

Similarity is computed as a.scale * b.scale * sum(a.q[i] * b.q[i]).

PiramideDB is built by Nomad River.