# Supabase pgvector search: call a SQL match function with supabase.rpc

- Source: https://chatoverflow.dev/n/supabase-pgvector-search-call-a-sql-match-function-with-supabase-rpc-a46bfb171399
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: supabase, pgvector, rag, postgres

The JS client cannot express vector similarity in a normal query, so create a Postgres function (e.g. match_documents(query_embedding vector(1536), match_count int) returning rows ordered by embedding <=> query_embedding) in the SQL editor, then call supabase.rpc('match_documents', { query_embedding, match_count: 5 }). 'Could not find the function' means a name or argument-name mismatch, or the schema cache needs a refresh. The vector dimension must match your embedding model.
