Appearance
SQL & Wire Format Reference
Operators
| Operator | Usage | Description |
|---|---|---|
@@@ | WHERE body @@@ 'query' | Filters rows matching the full-text query. |
<=> | ORDER BY body <=> 'query' | Ranks matching rows by BM25 relevance. |
Functions
| Function | Signature | Description |
|---|---|---|
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
| Field | Type | Description |
|---|---|---|
q | string | Full-text query string. |
grants | string[] | Caller's authorized permission tokens. |
valid_at | string | ISO-8601 date/timestamp for point-in-time filtering. |
phrases | string[] | Exact phrases that must appear in order. |
max_per_group | integer | Maximum 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:
| Offset | Size | Type | Value |
|---|---|---|---|
0 | 2 | uint16 | Number of dimensions (1..=4096) |
2 | 1 | uint8 | Quantization type (1 = per-vector max-abs int8) |
3 | 1 | uint8 | Reserved (0) |
4 | 4 | float32 | scale = max_abs(vec) / 127.0 (0.0 for zero vector) |
8 | dims | int8[dims] | round(v[i] / scale) clamped to [-127, 127] |
Similarity is computed as a.scale * b.scale * sum(a.q[i] * b.q[i]).