Retrieve candidates whose embeddings are similar#
Semantic search, recommendation retrieval, RAG, and image/audio similarity can represent items and queries as vectors. The index returns nearest candidates under a selected distance/similarity behavior; it does not determine factual correctness.
| Exact nearest neighbor | Approximate nearest neighbor |
|---|---|
| Compares enough vectors to preserve exact result semantics | Trades some recall for lower search cost and latency |
| Expensive at huge scale | Requires index tuning and recall measurement |
HNSW and IVF are example ANN families, not required base-level internals. Keep authoritative metadata in a primary database or document store and join/filter it with the vector index where needed.
- Claiming ANN is exact.
- Calling similar vectors “correct answers.”
- Replacing transactional storage with a vector index by default.
Related practice problems
Use the manifest-backed prompts below to apply this lesson in a complete design.
- Vector Search overviewGoogle Cloud Documentation