Flashcard: what is similarity search in RAG, and how does it differ from keyword search?
Similarity search finds the top-k chunks whose vectors sit closest to the query vector, so retrieval works on meaning rather than literal word overlap.
Picture every sentence as a point on a giant invisible map, where points sit close together when the sentences mean the same thing, even if they share no words. A user asks 'how do I cancel my plan'. We drop a pin where their question lives on the map, then look at the nearest neighbors. A document that says 'steps to terminate your subscription' lives almost at the same spot, so it shows up. A keyword search would never find that document, because the words 'cancel' and 'plan' are nowhere in it. Similarity search wins on meaning. The catch is that exact things, like product names or IDs, can drift apart in this map; for those, keyword search still wins. That is why production systems often run both and combine the scores.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: define similarity search as nearest-neighbor lookup under cosine, contrast with BM25 on the cancel versus terminate example, then call out hybrid retrieval and reranking as the 2026 production default.
Real products, models, and research that use this idea.
- Pinecone and Qdrant exposing native hybrid search that combines dense vector similarity with sparse keyword scores in a single query.
- Cohere Rerank 3 as a cross-encoder reranker on top of similarity search candidates, used widely in 2026 production RAG stacks.
- Weaviate's hybrid search shipping reciprocal rank fusion of BM25 and vector scores by default for customer support RAG.
- Elasticsearch / OpenSearch combining BM25 with kNN vector search in a single index, common in enterprise log and doc search platforms.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is cosine similarity preferred over Euclidean distance for embedding retrieval?
QHow would you build a hybrid retriever, and how would you fuse the two score lists?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Believing vector retrieval is strictly better than keyword retrieval. Exact tokens like product names, SKUs, and code identifiers often retrieve better with BM25; hybrid search exists because both have failure modes.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.