The pattern
- Declare a fixed-width vector column whose dimension matches your model’s output.
- Declare a vector index on it with the same dimension and a distance metric.
- Embed your text and append the vectors alongside the rows.
Embed your queries with the same model at search time, and pass the query vector to
vector_search (see Search).Choosing a metric
Match the index metric to how your embeddings are produced:| Metric | Use when |
|---|---|
cosine | embeddings are normalized (most sentence-transformer and OpenAI models) |
l2sq | you want squared Euclidean distance |
negdot | you want dot-product similarity over unnormalized vectors |
