Skip to content

Specialised stores · 2 of 4

Vector search: fast and wrong

Step 1 · The pattern

Find the closest documents

Each help article is stored as an embedding. A question is embedded too, and the store returns the articles closest to it. With a few thousand articles, comparing the question with every one takes 300 ms and is always right. (All numbers are illustrative.)

  • a question
  • right document

In short

Vector search: fast and wrong: how it works and how it breaks

A vector database stores embeddings, lists of numbers that place similar texts or images near each other, and answers 'what is closest to this?'. Exact search compares the query with every vector: always right, but it gets slower as the collection grows. Approximate indexes such as HNSW and IVFFlat answer in milliseconds by checking only part of it, and the price is recall: sometimes the nearest document is not returned. Tuned for speed, an AI assistant built on top cites the second-best document, or none, and nothing errors or alerts. Treat recall as a number you measure: compare the index's answers with exact search on a sample of real queries, tune the search effort (ef_search in HNSW, probes in IVFFlat) until recall is where you need it, fetch a few more candidates and re-rank them, and re-measure whenever the data or the embedding model changes.

What this simulation simplifies

  • Misses are a fixed chance here; real recall depends on the data, the query and the index settings.
  • Index build time and memory are not shown.

How this comes up in interviews

"Design document retrieval for an AI support assistant over 10 million documents."

Then they ask

  1. Exact or approximate search?
  2. How do you know the search is good enough?
  3. What happens when you change embedding models?

A strong answer covers

  • Approximate index (HNSW or IVF) for latency; exact search for evaluation.
  • Measure recall on real queries; tune search effort and re-rank.
  • Hybrid with keyword search for exact terms.
  • Re-embed and rebuild side by side on model changes.
  • Track answer quality, not just latency and errors.

Points to cover, not a script. Say them in your own words and tie them to a system you have worked on.

On one page: the track cheat sheet.

Last reviewed: Official documentation

Diagrams are our own simulations: the timings, rates and counts in them are illustrative, not measurements. Captions are original wording.