Vector Search
Vector search retrieves the items whose embeddings are nearest a query vector, turning semantic similarity into an index lookup.
Definition
Vector search — also called similarity search — accepts a query embedding and returns the stored vectors closest to it under a distance metric. The naive method scores every vector, which is fine for thousands of items but too slow for millions, so production systems use approximate indexes that trade a small, measurable recall loss for large gains in latency and memory.
Context and scope
The retrieval core of semantic search, recommendation, deduplication, and retrieval-augmented generation, where exact keyword matching cannot express the user intent.
Common misconceptions
- Vector search replaces keyword search entirely — hybrid retrieval that fuses lexical and vector scores usually beats either alone
- Recall is free — every approximate index trades recall for speed; recall must be measured against the intended workload
- Similarity score is a calibrated probability — a cosine score ranks items but is not a probability that a result is relevant
Anti-patterns
- Returning top-k results with no score threshold, flooding context with weakly related items
- Filtering by metadata after retrieving neighbours, which silently drops results and skews recall
- Indexing without normalising vectors when the metric assumes unit length
Related concepts
Related examples
Authoritative source
What it is
Vector search is nearest-neighbour lookup over embeddings. A query is embedded with the same model used to embed the corpus; the index returns the ids of vectors with the smallest distance to that query. Exact search is a linear scan; approximate indexes such as graph or hashed structures prune the search space and return almost the right answer far faster.
Why it matters
It is the machinery behind semantic retrieval. Instead of matching surface tokens, it matches meaning, which makes it effective across paraphrase, spelling errors, and multiple languages. In retrieval-augmented generation it selects the passages a model should read, so its recall directly bounds answer quality.
How to use it well
Pick the metric to match how the embedding was trained, normalise when the metric expects it, and combine vector scores with lexical ranking in a hybrid retriever. Pre-filter by metadata inside the index rather than after the search, set a similarity floor to avoid weak neighbours, and continuously measure recall on a labelled set so the approximation stays honest.