Semantic search relies on representing textual data as high-dimensional vector embeddings. In this article, we enable the pgvector extension inside a managed Supabase database and write Cosine Similarity queries using Prisma.
Setup Extension
Enable the extension inside your database migrations:
CREATE EXTENSION IF NOT EXISTS vector;
Next, define the vector column on your research documents table:
ALTER TABLE "ResearchDocument" ADD COLUMN embedding vector(1536);
We perform cosine similarity searches using custom database functions triggered via RPC.