Summary: Retrieval is the hardest part of documentation search. Keyword search (BM25) finds exact matches but misses paraphrases. Semantic search (embeddings) understands meaning but returns irrelevant results. Hybrid search (both combined) wins 30% more relevance than either alone. Best practice: start hybrid, add reranking and caching for production, monitor retrieval quality continuously.


Section 1: Why Retrieval Is the Bottleneck

Why This Matters

Documentation search feels simple until it isn’t. A user asks “How do I authenticate users?” Your system searches your docs. It either returns the right answer or it doesn’t.

The problem: traditional documentation search fails 30-40% of the time. Users get results for the wrong concept. They can’t find the information they need. They ask in Slack instead of searching. Your support team gets interrupted.

The deeper problem: most teams optimize for LLM quality and ignore retrieval. They think “If I use a better model, I’ll get better answers.” But the LLM can only generate good answers if it retrieves the right source documents first. Garbage in, garbage out.

Teams that fix retrieval see:

  • 30% fewer support tickets

  • 40% higher chatbot adoption

  • 60% better user satisfaction

But most get retrieval wrong. They pick the first tool they find, don’t test it properly, and assume it works. It doesn’t.

Related: if you’re tuning retrieval quality, start with How to Improve RAG Accuracy and pair it with How to Reduce Hallucinations in a Documentation Chatbot.

The Answer

Documentation retrieval is the problem you must solve before optimizing anything else. Four approaches exist:

  1. Keyword search (BM25) — Fast, exact matches, limited semantic understanding

  2. Semantic search (embeddings) — Understands meaning, slower, inconsistent quality

  3. Hybrid search — Combines both, best relevance, slightly higher latency

  4. Reranking — Takes top results, re-ranks by relevance, catches context the retriever missed

The right choice depends on your docs, your latency budget, and your team’s infrastructure capacity.

Evidence

  • Retrieval impact: 50% of chatbot answer quality depends on retrieval, not the LLM retrieval-research

  • Hybrid advantage: Hybrid search delivers 30% better accuracy than semantic alone benchmark-study

  • Reranking ROI: Adding reranking improves top-1 accuracy by 15-20% reranking-paper

Key Takeaway

The LLM is not your bottleneck. Retrieval is. Fix retrieval first, and answer quality improves dramatically without changing your LLM.

Section 2: Four Retrieval Strategies Compared

Strategy 1: Keyword Search (BM25)

What it is: Index every word in your docs, rank by word frequency and document relevance.

How it works:

  • User asks: “How do I authenticate users?”

  • System searches for docs containing “authenticate,” “auth,” “login,” “password”

  • Ranks results by relevance score (BM25 algorithm)

  • Returns top 5 results

Pros:

  • ✅ Fast (10-50ms latency)

  • ✅ Works without ML (no embeddings needed)

  • ✅ Explainable (you know why each result ranked)

  • ✅ Handles rare words well

  • ✅ No embedding costs

Cons:

  • ❌ Exact keyword matching only

  • ❌ Misses paraphrased questions (“How do I verify user identity?” might not match “authenticate”)

  • ❌ Struggles with synonyms

  • ❌ No semantic understanding

Best for: Internal docs, technical reference, exact-match use cases

Tools:

  • Elasticsearch (self-hosted, 0 cost)

  • Solr (self-hosted, 0 cost)

  • PostgreSQL full-text search (free, built-in)

  • Typesense (managed, $99-400/month)

Latency: 10-50ms

Strategy 2: Semantic Search (Dense Embeddings)

What it is: Convert docs and questions to numerical vectors (embeddings), find nearest neighbors.

How it works:

  • System converts question “How do I authenticate users?” to embedding vector

  • Converts all doc chunks to embedding vectors (done once, stored)

  • Finds most similar vectors to question vector

  • Returns top 5 docs by similarity score

Pros:

  • ✅ Understands meaning and paraphrases

  • ✅ Catches synonyms and related concepts

  • ✅ Works well with conversational questions

  • ✅ Better for “soft matching”

Cons:

  • ❌ Slower (300-2000ms latency)

  • ❌ Requires embeddings (external API or self-hosted GPU)

  • ❌ Embedding cost ($0.01-0.05 per question if using OpenAI)

  • ❌ Quality varies by embedding model

  • ❌ Can return tangentially related docs

  • ❌ Struggle with rare/domain-specific terms

Best for: Conversational search, paraphrased questions, customer-facing chatbots

Tools:

  • Pinecone (managed vector DB, $25-500+/month)

  • Weaviate (managed, $25/month starting)

  • Qdrant (self-hosted or managed, free-$100/month)

  • Milvus (self-hosted, free)

  • pgvector (PostgreSQL extension, free)

Embedding models:

  • OpenAI text-embedding-3-small ($0.02/1M tokens)

  • Cohere embed-english-3 ($0.10/1M tokens)

  • sentence-transformers/all-MiniLM-L6-v2 (free, self-hosted)

Latency: 300-2000ms

Strategy 3: Hybrid Search (Keyword + Semantic)

What it is: Run both BM25 and semantic search, combine results intelligently.

How it works:

  1. User asks: “How do I authenticate users?”

  2. Run BM25 search → Get results ranked by exact keyword match

  3. Run semantic search → Get results ranked by meaning similarity

  4. Combine rankings (weighted blend or RRF - Reciprocal Rank Fusion)

  5. Return top 5 combined results

Pros:

  • ✅ Best of both worlds (exact matches + semantic understanding)

  • ✅ 30% better accuracy than semantic alone

  • ✅ Catches both rare keywords and paraphrased questions

  • ✅ More robust to query variation

  • ✅ Moderate latency (300-1000ms)

Cons:

  • ⚠️ Requires both BM25 and embedding infrastructure

  • ⚠️ More complex to set up

  • ⚠️ Tuning weights for combination takes iteration

  • ⚠️ Higher operational complexity

Best for: Production documentation systems, high-quality requirements

Tools:

  • Elasticsearch with vector search (self-hosted or managed, $0-300/month)

  • Weaviate hybrid mode (free or managed)

  • Qdrant hybrid search (free or managed)

  • Milvus with BM25 integration (free)

  • Custom setup: PostgreSQL + pgvector + full-text search

Latency: 300-1000ms

Strategy 4: Reranking (Refinement Layer)

What it is: Retrieve top 10 results using any method, then use a specialized model to re-rank them.

How it works:

  1. Retriever (BM25 or semantic) returns top 10 results (fast, broad)

  2. Reranker reads each result and question, scores relevance (slow, precise)

  3. Re-ranks results by new scores

  4. Returns top 3-5 re-ranked results

Why it works: Retrieval is fast but imprecise. Reranking is slow but precise. Running reranking on top-10 balances both.

Impact:

  • 15-20% improvement in top-1 accuracy

  • 10-15% improvement in top-3 accuracy

  • Only adds 200-500ms latency (rerank 10 docs, not 1000)

Pros:

  • ✅ Improves any retrieval method

  • ✅ Works as a second stage (doesn’t replace retriever)

  • ✅ Can use expensive models (applies to only 10 docs)

  • ✅ Easy to add to existing systems

Cons:

  • ❌ Adds latency (200-500ms additional)

  • ❌ Requires external API or self-hosted model

  • ❌ Cost adds up (if using pay-per-token model)

Best for: When answer quality is critical, user will wait 1-2 seconds

Reranking models:

  • Cohere rerank-english ($0.001 per document, fast)

  • Cross-encoders from HuggingFace (free, self-hosted)

  • jina-reranker-v1 (free API)

  • Custom fine-tuned models (expensive but highest quality)

Latency: +200-500ms (to existing retrieval time)

Key Takeaway

No single strategy is best. Hybrid is the starting point for production systems. Add reranking if answer quality matters more than speed. Use BM25 alone only for internal or simple docs.

Section 3: Comparison Matrix

Feature

BM25

Semantic

Hybrid

Hybrid + Reranking

Accuracy

60%

75%

85%

95%+

Latency

10-50ms

300-2000ms

300-1000ms

500-1500ms

Setup Complexity

Simple

Moderate

Moderate

Complex

Cost/Month

$0-50

$50-500

$50-500

$100-800

Best For

Exact matches

Conversational

Production

High-stakes Q&A

Handles synonyms

Handles rare terms

Handles paraphrases

Infrastructure

Search engine

Vector DB

Both

Both + Reranker

Section 4: Vector Databases (The Core Infrastructure)

Managed Vector Databases (Easiest)

Pinecone

  • Cost: $25-500+/month

  • Setup: 5 minutes

  • Scaling: Automatic

  • Upsides: Simplest setup, instant scaling, no ops

  • Downsides: Vendor lock-in, costs climb with scale

  • Best for: Teams that prioritize speed over cost

Weaviate Cloud

  • Cost: $25-1000/month

  • Setup: 10 minutes

  • Scaling: Auto-scaling available

  • Upsides: Hybrid search built-in, strong documentation

  • Downsides: Less familiar than Pinecone

  • Best for: Hybrid search, European data residency requirements

Supabase (pgvector)

  • Cost: $25-500/month

  • Setup: 15 minutes

  • Scaling: Scales with Postgres

  • Upsides: Built on Postgres (familiar), no vendor lock-in

  • Downsides: Requires Postgres knowledge

  • Best for: Teams already using Postgres

Self-Hosted Vector Databases (Most Control)

Milvus

  • Cost: $0 (infrastructure only)

  • Setup: 1-2 hours (Docker)

  • Scaling: Manual, requires ops

  • Upsides: No vendor cost, full control, high performance

  • Downsides: Ops burden, scaling complexity

  • Best for: Teams with DevOps capacity, large scale

Qdrant

  • Cost: $0 (infrastructure only)

  • Setup: 1-2 hours (Docker)

  • Scaling: Raft-based replication, manageable

  • Upsides: Good performance, replication support

  • Downsides: Ops burden, scaling still requires work

  • Best for: High-performance requirements, willing to manage infrastructure

Chroma

  • Cost: $0 (infrastructure only)

  • Setup: 30 minutes

  • Scaling: Limited, good for <1M documents

  • Upsides: Simplest self-hosted option

  • Downsides: Doesn’t scale to massive datasets

  • Best for: Prototypes, small-to-medium docs

PostgreSQL + pgvector

  • Cost: $0 (extension, infrastructure is Postgres)

  • Setup: 15 minutes

  • Scaling: Scales with your Postgres

  • Upsides: One less database, familiar SQL

  • Downsides: Performance degradation at 10M+ vectors

  • Best for: Small-to-medium datasets, prefer single DB

Decision Framework





Key Takeaway

For production, start managed (Pinecone/Weaviate). Migrate to self-hosted Qdrant only when costs justify the ops burden (usually >1M documents, >$5K/month spend).

Section 5: Optimization Techniques

Technique 1: Better Chunking

Problem: How you split docs into chunks affects retrieval quality.

What goes wrong:

  • Chunks too small (100 tokens) → Lost context

  • Chunks too large (1000 tokens) → Retriever returns document instead of answer

  • Naive splitting (every 300 tokens) → Splits mid-sentence, mid-concept

Better approach:

  • Split on boundaries (sentences, paragraphs, sections)

  • Use semantic units (each chunk answers one concept)

  • Keep surrounding context (include 1-2 sentences before/after each chunk)

  • Aim for 300-500 tokens per chunk

Impact: 10-15% improvement in retrieval accuracy

Technique 2: Caching (Retrieval Cache)

What it is: Cache common queries so you don’t re-retrieve every time.

Example:

  • User 1 asks: “How do I authenticate users?”

  • System retrieves docs, caches result

  • User 2 asks same question

  • System returns cached result (instant)

Impact:

  • 50-80% latency reduction for common questions

  • Reduces embedding API costs (no redundant calls)

  • Reduces vector DB queries

Tools:

  • Redis (free, self-hosted)

  • Memcached (free, self-hosted)

  • Upstash (managed Redis, $1-100/month)

Technique 3: Query Expansion

What it is: Rewrite user question to include synonyms and related terms.

Example:

  • User asks: “How do I authenticate users?”

  • System expands to: “How do I authenticate users? user authentication, login, password verification, OAuth, token-based auth”

  • Searches for all terms

  • Returns better results

Impact: 5-10% improvement in retrieval for rare/specific questions

Technique 4: Metadata Filtering

What it is: Filter results by doc metadata before ranking.

Example:

  • User in “pricing” section asks “What does this cost?”

  • Retriever can filter to only pricing docs first

  • Then rank within that subset

Impact: 5-15% improvement when metadata is relevant

Key Takeaway

Chunking and caching are quick wins. Query expansion and metadata filtering require more setup but improve specific scenarios. Start with chunking.

Section 6: Common Retrieval Mistakes

Mistake 1: Ignoring Retrieval Quality

What goes wrong: Teams launch with whatever retrieval is easiest, don’t measure quality.

Result: Users ask, system returns wrong docs, LLM generates plausible-sounding wrong answers, users lose trust.

How to avoid it:

  • Measure retrieval accuracy independently (before adding generation)

  • Test: “For 100 real user questions, does the system retrieve the right doc 85%+ of the time?”

  • Use retrieval evals (not just LLM evals)

Mistake 2: Using Embeddings Without Testing

What goes wrong: Teams assume “embeddings are magic” and will work. They don’t without tuning.

Example: You’re using OpenAI embeddings, but your docs are highly technical. OpenAI embeddings are trained on general text, not your domain. Result: Poor retrieval.

How to avoid it:

  • Test 3-5 embedding models on your actual docs

  • Run a quick benchmark: do 10 questions, see which model returns right docs

  • Domain-specific models (like domain embeddings) often outperform general models 20-30%

Mistake 3: Keyword Search Only (Not Using Semantic)

What goes wrong: You use BM25, assume it’s good enough. It’s not for conversational questions.

How to avoid it:

  • Use hybrid from the start

  • You’ll get better results and catch both exact matches and paraphrases

Mistake 4: High Latency (Not Using Caching/Reranking)

What goes wrong: Each query takes 2+ seconds (slow vector DB lookups). Users abandon the chatbot.

How to avoid it:

  • Add caching (instant for common questions)

  • Use reranking to cut vector search scope (retrieve top-20 with fast method, rerank to top-3)

Mistake 5: Poor Chunking Strategy

What goes wrong: You split docs naively (every 300 tokens). Chunks are mid-sentence, mid-concept. Retriever returns noise.

How to avoid it:

  • Split on document structure (sections, paragraphs)

  • Test retrieval quality with different chunk sizes

  • Chunk size matters: 300-500 tokens is usually right

Key Takeaway

Most teams get retrieval wrong because they don’t measure it. Start measuring retrieval quality before you measure LLM quality. If retrieval is 85%+, the LLM will do well.

Section 7: Production Readiness Checklist

A production retrieval system has:

Core (Non-Negotiable)

  • Hybrid search (BM25 + semantic)

  • Retrieval accuracy tracked (aiming for 85%+)

  • Latency <1 second for 95th percentile

  • Search quality evals (automated tests for 50+ real queries)

Recommended

  • Query caching (Redis or equivalent)

  • Reranking for high-stakes queries

  • Semantic chunking (300-500 tokens, preserve context)

  • Metadata filtering if applicable

Advanced

  • Query expansion for rare terms

  • Domain-specific embedding models

  • A/B testing retrieval improvements

  • Monitoring of retrieval drift (quality degrading over time)

Key Takeaway

Production-ready doesn’t mean fancy. It means: measure retrieval quality, use hybrid search, keep latency low, monitor continuously.

Section 8: Implementation Roadmap

Week 1: Baseline (BM25)

  • Set up Elasticsearch or PostgreSQL full-text search

  • Index your docs

  • Test retrieval on 20 representative questions

  • Measure baseline accuracy

Effort: 10-20 hours
Cost: $0-100/month

Week 2: Add Semantic Search

  • Choose embedding model (test 2-3 options)

  • Set up vector DB (managed is faster, self-hosted is cheaper)

  • Generate embeddings for all docs

  • Implement hybrid search (combine BM25 + semantic)

Effort: 15-30 hours
Cost: $50-500/month

Week 3: Optimize & Monitor

  • Set up retrieval quality monitoring

  • Add caching for common queries

  • Tune chunk size based on retrieval evals

  • Create dashboard tracking retrieval accuracy

Effort: 10-20 hours
Cost: $0-100/month

Week 4: Scale & Rerank (Optional)

  • Add reranking for high-stakes questions

  • Implement query expansion

  • Set up A/B testing for retrieval changes

  • Monitor for retrieval drift

Effort: 15-30 hours
Cost: $100-300/month

Total to production: 4 weeks, $150-1000/month depending on choices

Conclusion

Retrieval is the hardest part of documentation search, and it’s the part that determines answer quality. Most teams optimize the wrong things (better LLM, fancier UI) and ignore retrieval.

The fix is straightforward:

  1. Start hybrid. BM25 + semantic search, combined, beats either alone.

  2. Measure quality. Track retrieval accuracy independently. Aim for 85%+.

  3. Optimize details. Chunking, caching, reranking all give 10-20% improvements.

  4. Monitor continuously. Set up dashboards. Catch quality degradation immediately.

Teams that get retrieval right see 60% better adoption and 40% fewer support tickets. Not because their LLM is better. Because their users actually find the information they need.

Related Articles

References

Frequently Asked Questions

Frequently Asked Questions

What is the best retrieval method for documentation search?
There is no single best method, but hybrid search (keyword plus semantic) is the right starting point for production. It combines exact keyword matching with semantic understanding and delivers around 30% better accuracy than semantic search alone, catching both rare terms and paraphrased questions. Add reranking on top when answer quality matters more than speed.

What is the difference between keyword, semantic, and hybrid search?
Keyword search (BM25) is fast and finds exact matches but misses paraphrases and synonyms. Semantic search uses embeddings to understand meaning and handle conversational questions but is slower and can return tangentially related results. Hybrid search runs both and combines the rankings, getting the exact-match strength of keyword search and the meaning-awareness of semantic search.

Why is retrieval more important than the LLM for answer quality?
An LLM can only generate a good answer if it retrieves the right source documents first, so retrieval quality sets the ceiling on answer quality. Around half of a chatbot's answer quality depends on retrieval rather than the model, which is why fixing retrieval improves answers without changing the LLM. Most teams over-invest in the model and under-invest in retrieval.

What does reranking do and is it worth adding?
Reranking retrieves a broad set of top results with a fast method, then uses a specialized model to re-score and reorder them by relevance. It improves top-1 accuracy by roughly 15-20% and only adds about 200-500ms of latency, since it scores around ten documents rather than thousands. It is worth adding when answer quality is critical and users will wait a second or two.

Which vector database should I use for documentation search?
For production, starting with a managed vector database like Pinecone or Weaviate is fastest, since setup takes minutes and scaling is automatic. Self-hosted options like Qdrant or Milvus cut cost at large scale but require DevOps capacity, and PostgreSQL with pgvector is a good fit if you already run Postgres and your dataset is under a few million vectors. Migrate to self-hosted only once cost justifies the operational burden.

How do I improve documentation retrieval accuracy?
Start with hybrid search, then measure retrieval accuracy independently and aim for 85% or higher on real questions. The highest-leverage tuning is better chunking (split on document structure at 300-500 tokens), with caching for common queries, query expansion for rare terms, and metadata filtering as further gains. The key habit is measuring retrieval quality before measuring the LLM.

TRUSTED BY 200+ INDUSTRY-LEADING ENTERPRISES WITH COMPLEX PRODUCTS
  • Silicon Labs
    Ask anything...
  • Logitech
    Ask anything...
  • n8n
    Ask anything...
  • monday.com
    Ask anything...

Turn technical documentation into customer-facing AI assistants