Skip to main content

Dense Retrieval vs Keyword Search

A comparison of two search approaches: neural network-based semantic retrieval (Dense Retrieval) and traditional keyword matching (Sparse / BM25). It explains why vector search may fail in product item searches and how hybrid search operates.

1. Concept Overview & Systemic Problem

When vector databases emerged in 2023, many enthusiasts proclaimed: “Traditional text search is dead! Now everything will be searched through neural vectors!”

However, when companies began implementing pure vector search in real e-commerce sites or warehouses, problems arose:

  • A customer inputs the exact part code: A211-540-00-44 ➔ vector search returns similar parts with different digits!
  • A lawyer searches for case number № 752/1234/25 ➔ vector search shows entirely different court rulings with similar words.

It turned out that each method has its strengths and blind spots:

  • Dense (Vector Search): unmatched for understanding ideas, abstract queries, and synonyms.
  • Sparse / Keyword (BM25): indispensable for searching exact items, codes, passport numbers, and rare surnames.

2. Architectural Taxonomy & Mental Model

┌─────────────────────────────────────────────────────────────┐
│                 WHO WILL FIND THE ANSWER BETTER?          │
├──────────────────────────────┬──────────────────────────────┤
│ 🔍 User Query:               │ 🏆 Who Wins and Why:         │
├──────────────────────────────┼──────────────────────────────┤
│ “Affordable family car”      │ 🟢 DENSE (Vector Search):    │
│                              │ Understands the meaning and   │
│                              │ finds SUVs and minivans       │
├──────────────────────────────┼──────────────────────────────┤
│ “Oil filter OC-90”          │ 🔵 BM25 (Keyword Search):     │
│                              │ Instantly finds the exact index│
│                              │ without guessing neighboring parts│
├──────────────────────────────┼──────────────────────────────┤
│ “How to reduce fever at night”│ 🟢 DENSE (Vector Search):    │
│                              │ Finds paracetamol and         │
│                              │ antipyretic medications        │
├──────────────────────────────┼──────────────────────────────┤
│ “Article 115 part 2 of the Criminal Code”│ 🔵 BM25 (Keyword Search):  │
│                              │ Finds exactly this article, not │
│                              │ general considerations about crime│
└──────────────────────────────┴──────────────────────────────┘

3. Technical Pipeline & Internal Mechanics

Today, no professional architect chooses just one method. The industry standard has become the hybrid approach:

                  ┌────────────────────────┐
                  │      User Query        │
                  └───────────┬────────────┘
                              │
              ┌───────────────┴───────────────┐
              ▼                               ▼
     [Vector Dense]                 [Traditional BM25]
     (Meaning-Based Search)       (Item-Based Search)
              │                               │
              └───────────────┬───────────────┘
                              ▼
               ┌─────────────────────────────┐
               │      Merging Lists (RRF)    │
               │   Best Common Findings      │
               └─────────────────────────────┘

4. Production Engineering Scenarios

If you are building a search for an e-commerce site or documentation catalog:

  • Do not discard traditional keyword search!
  • Use databases that natively support hybrid search (e.g., Qdrant or PostgreSQL with a combination of pgvector and tsvector). This ensures that your users can find products both by description like “nice red dress” and by exact item code SKU-881!

01. E-Commerce Product Search

Implement a hybrid search to allow users to find products by both general descriptions and specific SKUs, enhancing user experience and conversion rates.

02. Legal Document Retrieval

Utilize BM25 for precise legal queries while employing dense retrieval for broader context searches, ensuring comprehensive results for legal professionals.

03. Medical Information Lookup

Combine dense retrieval for symptom-related queries with keyword search for exact medication names, providing accurate and relevant medical information to users.

5. Pitfalls, Common Mistakes & Security

  • Over-reliance on Vector Search: Avoid assuming that vector search will always yield relevant results; it may misinterpret specific queries.
  • Ignoring User Intent: Failing to understand the user's intent can lead to poor search results; always consider the context of the query.
  • Security Vulnerabilities: Ensure that both search methods are secured against injection attacks and data leaks, particularly when handling sensitive information.
/ Frequently Asked QuestionsSchema.org FAQPage

FAQ: Dense Retrieval vs Keyword Search

Vector search looks for overall SENSE. For it, items like 'SKU-99214' and 'SKU-99215' are nearly identical in coordinates (just abstract sets of digits of the same class). If a user searches for an exact part code or a medication name by series, traditional exact match search (BM25) will perform 100 times better.
/ Internal links
All terms