Run semantic search on embeddings from SQL
Semantic search is often implemented in a separate vector database. You can store embeddings in the workspace, build vector indexes, and run nearest-neighbor queries alongside standard SQL. This allows you to combine semantic similarity with relational filters in a single query.
How it works
Step 1 — Pick a table and text or vector column
Open the help articles table in our support KB and show the columns—I need to pick which field to use for meaning-based search.Step 2 — Create a vector index
Index article bodies for semantic (meaning-based) search, using cosine to compare how close two pieces of text are.With --async, the build runs as a background job (embedding generation + index materialization can take a while)—poll hotdata jobs until it finishes.
Step 3 — Search from the CLI with an embedding model
Ask in plain language how refunds work and return the ~10 help articles that best match the question by meaning.Step 4 — Same retrieval in SQL
Do that kind of search in SQL: closest matches first, with id, title, and how far each row is from the question—10 rows.When an HNSW-capable ORDER BY … LIMIT pattern matches and the index is ready, the planner can answer nearest-neighbor without scanning the full table—otherwise distance still computes correctly, just slower.
Who uses this
- Support and documentation search ranked by semantic similarity.
- Product catalogs that combine similarity scores with relational filters.
- Agents returning nearest-neighbor rows with distance in the same request path as other SQL.