Repository navigation
v0.6.1
The first release of filtered and hybrid search. The v0.6.0 tag was created but never
released: its upgrade filled a full-text column by rewriting every existing chunk row, which
re-inserted every vector into the HNSW index and could change approximate results after the
upgrade. v0.6.1 indexes full text with a concurrently built expression index instead, so an
upgrade rewrites no chunk of a pipeline without metadata. Upgrade from v0.5.0 directly to
v0.6.1.
Filtered, full-text and hybrid search: /search can rank by full-text match as well as by
embedding, fuse both with reciprocal rank fusion, and restrict results by typed metadata
and by a tenant from a trusted gateway. Design and examples: docs/search.md.
Added
- Modes:
modeselectsvector(default, unchanged),text(PostgreSQL full-text search,
websearch_to_tsqueryoversearch.text_config, no embedding call) orhybrid(both
branches fused with reciprocal rank fusion,score = sum of 1 / (rrf_k + rank), default
rrf_k60 fromsearch.rrf_k, overridable per request). Hybrid hits reportranks, their
rank in each branch that returned them. - Metadata:
metadata:on a pipeline or view declares filterable columns (text,int,
float,bool,timestamp,text_array). Metadata is stored with every chunk and is not
embedded: changing it never re-embeds a document. - Filters: a recursive
filter(and,or,notand the conditionseq,ne,in,
range,contains,exists), in the POST body or the URL-encodedfilterparameter of GET.
A missing field fails every comparison,neincluded;notof a condition matches documents
without the field. - Pipeline restriction:
pipelines(POST) andpipeline(GET, comma-separated). - Tenant scope:
search.tenant_filter: {field, header}adds<field> eq <header>to every
branch. Requests without the header get400 tenant_required; a filter on the tenant field gets
400 tenant_filter_forbidden. embedsync does not authenticate callers: the header must be set by
a gateway. - Configuration:
search.text_config(defaultsimple) andsearch.rrf_k(default 60). - CLI:
embedsync searchgains--mode,--filter,--pipelineand--tenant. - Status: each generation reports
search(buildingorready) inembedsync status
(text and--json, fieldgenerations[].search).embedsync verifyreports
meta_staleper generation and pipeline andfts_index_missingper generation. - Schema:
sink/0005_search.sqladdsmeta(jsonb, GIN-indexed) to every chunk table, and
search_targetandsearch_fingerprinttogenerations. Full text uses an expression index
per chunk table,<table>_fts_<text_config>onto_tsvector(<text_config>, content), built
concurrently byrun. - Examples and docs:
examples/embedsync-search.yamlandexamples/seed-search.sql,
docs/search.md, and the search section of the README. The LangChain and LlamaIndex
retrievers takemode,pipelines,filterandheaders. - Error bodies:
/searcherrors are JSON{error, code, field}. The codes are listed in
docs/search.md and inapi/openapi.yaml.
Changed
/searcherrors: client errors are now400(invalid request, filter or tenant),
404(unknown generation or pipeline),405(method other than GET or POST) and413
(POST body over 1 MiB). Previously every failure was503.503is kept forsearch_index_building(withRetry-After) and
for backend failures.- POST /search takes a JSON body. A POST that sends the legacy query string (
?q=) without
a JSON content type is still answered as before. - Responses: every
/searchresponse carriesmode. Hybrid hits carryranks. Other
fields are unchanged. - Snapshot metadata: metadata columns are read during a snapshot with their type's output
function, the same text the replication stream sends (boolistorf, not the output of
an explicit cast). A backfill and the stream therefore store identical metadata. - Metadata validation:
runchecks each metadata column against its declared type when it
starts (floataccepts integer columns;textaccepts any column).
Upgrade notes
- Stop
embedsync run, install the new version, runembedsync init --admin-url <admin URL>
(or the admin DSN variables), then startrun.initappliessink/0005_search.sql: it adds
the column and index above and changes nothing else. Nothing is re-embedded. Adding the
column is instant; building its GIN index reads each chunk table once and blocks writes to it
meanwhile (reads, including search, continue), which is whyrunis stopped forinit. - After the upgrade,
runcompletes search in the background: it builds the full-text
expression index concurrently (no row is rewritten, so chunks of pipelines without metadata,
and their vector index, stay exactly as they were) and fills the metadata of pipelines and
views that declaremetadata:by a re-scan that reuses the stored vectors (those rows get new
versions; vacuum large tables afterwards). Until a generation is complete, filtered, text and
hybrid requests to it answer503 search_index_buildingwithRetry-After: 30. Vector
requests without a filter or tenant keep their results.embedsync statusshows
search=building, thensearch=ready. - Changing a
metadata:declaration orsearch.text_configstarts the same background rebuild
for each live generation. - Downgrading after
initis not supported.
Compatibility
- Legacy
GET /search?q=&k=&generation=&exact=is unchanged: the same hits, the same fields,
and an out-of-rangekstill falls back to 10 on GET. - Clients that treated every
/searchfailure as a transient503must handle400,404
and405. - Filtered vector search uses pgvector's iterative index scan, which needs pgvector 0.8.0 or
later. On an older pgvector a filtered request can return fewer thankhits with
exact: false;exact: truescans the table instead.