Skip to main content

Module search_vector

Module search_vector 

Source
Expand description

Rewrite SEARCH <coll> USING VECTOR(<field>, ARRAY[...], <k>) to the canonical SELECT * FROM <coll> ORDER BY vector_distance(<field>, ARRAY[...]) LIMIT <k>.

<field> may be omitted (and the third arg becomes the limit). When the collection has a single declared vector column the planner resolves the field; otherwise vector_distance rejects the call with a typed error.

The same clause is also accepted in subquery position — FROM (SEARCH ...) s, IN (SELECT id FROM (SEARCH ...) s) — so a k-NN result composes with joins and relational filters inside one statement.

Functions§

try_rewrite_nested_search_using_vector
Rewrite every (SEARCH <coll> USING VECTOR(...)) occurrence that sits in subquery position into (SELECT ...), leaving the rest of sql untouched.
try_rewrite_search_using_vector