surfacesearchvector_search
Searchaggregate · returns table

VECTOR_SEARCH

Find similar documents via vector search

Per-group — reads the whole group in one call.

searchllmtext

Arguments

nametypedescription
queryVARCHARSearch query text
source_tableVARCHARTable name to search
limit(optional)INTEGERMax results (default 10)
threshold(optional)DOUBLEMin similarity threshold (0-1)

About

Semantic search using DuckDB cosineDistance. Returns table of (id, text, similarity, distance) tuples. Pre-filters via vector similarity, can be combined with LLM operators. SQL Usage: -- Explicit form (DuckDB): SELECT * FROM read_json_auto(vector_search_json_3('eco-friendly products', 'products', 10)); SELECT * FROM read_json_auto(vector_search_json_4('query', 'table', 10, 0.7)); -- with threshold Performance: - Vector search: ~50ms for 1M vectors (ClickHouse native) - No LLM calls (pure vector similarity) - Results cached by query hash Hybrid Pattern (Vector + LLM): WITH takes AS ( SELECT * FROM VECTOR_SEARCH('eco products', 'products', 100) ) SELECT * FROM takes c JOIN products p ON p.id = c.id WHERE p.description MEANS 'eco-friendly AND affordable' ORDER BY c.similarity DESC;

Nearby rabbit holes

same domain
Climb back to The Looking Glass