{ arrow: true } there for an Arrow table). Pass a projection to choose which columns
come back.
Choose a search mode
Full-text (BM25)
Ranked keyword search over an FTS-indexed column.BM25
score is a similarity — higher is better. (Vector score is a distance; the two run in opposite directions.)Query syntax
Thequery string accepts three operators besides plain terms. They work the same in the
bm25_search SQL function.
A phrase needs the column indexed with
positions=True (see
Indexing); on a column without positions it is an error. A query made
only of excluded terms is also an error: give at least one positive term.
Counting matches
count returns how many rows match a BM25 keyword query, without fetching or ranking
them — cheaper than a search when you only need the tally.
Unranked lookups
When you don’t need scoring,token_match (rows containing a token) and exact_match
(rows whose column equals a value) return every matching row, unranked.
exact_match and token_match run over an FTS-indexed column. Index the column
you want to match, for example IndexSpec().fts("doc_id"), to look it up this way.Vector search
Semantic search over a vector-indexed column. Embed the query with the same model you used to index (see Embeddings).Vector
score is a distance, so lower is closer. For cosine and l2sq, 0.0 is a
perfect match; for negdot it is the negated dot product, so similar vectors score below
zero. This is the opposite direction from BM25’s score (a similarity, higher is better). Don’t compare
the two raw scores — hybrid search fuses them for you by rank.Pushdown filter
Restrict the kNN to rows whose FTS-indexed column matches a text predicate. This is a pre-filter, where the kNN ranks only among matching rows, not a post-filter on the top-k.
Filtering BM25, hybrid, or by a scalar column
filter is specific to the vector_search method. To filter a BM25 or hybrid search, or
to filter any search by a scalar column such as a tenant id, call the search as a
SQL table function and add a WHERE:
WHERE and
returns the top k of those.
Hybrid search
Hybrid search runs BM25 and vector kNN over the same table and fuses their rankings with reciprocal-rank fusion (RRF), which is strong when a query has both keyword and semantic intent. It’s a first-class method — pass the text query and the query vector, and it returns ranked rows like the other searches:
Hybrid search needs both indexes on the table: an
fts index on the text column and a
vector index on the embedding column. It’s also available in SQL via
the hybrid_search table function, where you can compose it with joins and filters.
Pagination
Searches return the topk; there is no offset argument and no cursor. To page through
results:
- In the SDK, ask for enough rows to cover the page you want (
k = page * page_size) and slice off the lastpage_size. - In SQL, use
LIMITandOFFSETover the search function.kstill bounds what the search returns, so it must be at leastOFFSET + LIMIT, or the later pages come back empty.
Limitations
- Vector search is approximate (IVF). It trades exactness for speed. Probe width
and rerank budget are calibrated by the engine per table and per
k; there are no tuning knobs to set. - Bring your own embeddings. Embed queries with the same model and dimension you indexed with.
- The
filteroption exists on vector search only, and takes a text predicate over an FTS-indexed column. For BM25, hybrid, or scalar filters, use a SQLWHERE, which is also applied inside the search. exact_matchandtoken_matchneed an FTS-indexed column.
