LIVEยทThe trends shaping tomorrow's world.
AI

Semantic Search vs Keyword Search

Keyword search matches words with BM25. Semantic search matches meaning with embeddings. How each works, where each fails, and how to choose for RAG.

Keyword search finds documents that contain the words in your query, ranked by a formula such as BM25 that rewards rare terms and repeated matches. Semantic search turns the query and the documents into embeddings (lists of numbers that encode meaning) and returns the documents whose embeddings sit closest to the query's, even when they share no words. Keyword search is precise on exact terms but misses paraphrases; semantic search handles paraphrases but can miss rare exact terms. Many production systems now run both.

Two ideas of "relevant"

Picture two librarians. The first has an index card for every word in every book, and hands you the books that mention your words most distinctively. The second has read everything and hands you the books that are about what you asked, whatever words they use.

Keyword search is the first librarian. Semantic search is the second. The first never confuses "E-4012" with "E-4021." The second knows that "bad guy" and "villain" mean the same thing. Neither does both reliably.

The authors of Dense Passage Retrieval (DPR), a foundational 2020 paper on embedding-based retrieval, used exactly that example. A term-based system would struggle to answer "Who is the bad guy in lord of the rings?" from a passage that says "Sala Baker is best known for portraying the villain Sauron," while a dense retriever could match "bad guy" to "villain" [2].

How keyword search works

Keyword search, also called lexical or full-text search, has three moving parts.

1. Analysis. Text is split into tokens, and usually lowercased and normalized, so "Running" and "running" match. The same steps run on the query.

2. The inverted index. For each term, the engine stores a list of the documents that contain it. Looking up a query is then a matter of fetching a few short lists, which is why keyword search is fast and cheap even on large collections. DPR's authors describe TF-IDF and BM25 as matching "keywords efficiently with an inverted index," effectively representing text as high-dimensional sparse vectors [2].

3. Scoring with BM25. BM25 is the classic ranking function for keyword search. Robertson and Zaragoza's survey lays out its ingredients [1]:

  • Rarity (IDF). A term that appears in few documents tells you more than one that appears everywhere, so it gets more weight.
  • Term frequency, with saturation. More occurrences of a term raise the score, but each term's contribution has a ceiling "however frequently it occurs in the document" [1]. A parameter, k1, controls how fast it saturates.
  • Length normalization. A long document mentions everything eventually, so BM25 discounts matches in documents longer than average. A parameter, b, sets how much: b = 1 is full normalization, b = 0 turns it off [1].

The model itself doesn't say how to set k1 and b. Experiments suggest values in the ranges 0.5 < b < 0.8 and 1.2 < k1 < 2 are "reasonably good in many circumstances," though the best values depend on the documents and queries [1].

What you get from this design: exact matching of codes, names and jargon; scores you can explain term by term; Boolean and phrase operators; and no machine-learning model to host.

What you give up: if the document doesn't use your words, it won't be found. The BEIR benchmark authors call this the lexical gap: lexical approaches "are able to only retrieve documents containing keywords present within the query," and they ignore word order [3].

How semantic search works

Semantic search, also called dense or vector retrieval, also has three parts. Our explainers on embedding models and vector databases cover each in depth.

1. Embedding. A neural network maps each document chunk to a vector, a fixed-length list of numbers. Texts with similar meaning land near each other. DPR trained two encoders, one for questions and one for passages, so that a question's vector lands near the vectors of passages that answer it [2].

2. Indexing. The vectors go into an approximate nearest neighbor (ANN) index such as HNSW or IVF, which can search millions of vectors without comparing against every one.

3. Querying. The query is embedded with the same model, and the index returns the k nearest document vectors, by cosine similarity or inner product.

What you get: matches on meaning, so paraphrases, synonyms and natural-language questions work. DPR reported that its dense retriever beat a Lucene BM25 system on top-20 passage retrieval accuracy across several open-domain QA datasets [2].

What you give up:

  • Rare, exact terms. DPR's authors noted that their model "might lack sufficient capacity to represent salient phrases which appear rarely," while BM25 is "sensitive to highly selective keywords and phrases" [2].
  • Robustness to new domains. On BEIR's 18 datasets, BM25 proved "a robust baseline," and dense retrievers often underperformed when tested outside the domain they were trained on [3].
  • Datasets that favor word overlap. On SQuAD, where annotators wrote questions after reading the passage, DPR trailed BM25. Its authors attribute this partly to the "high lexical overlap" between questions and passages [2].
  • Explainability. You can't point to the term that caused a match; similarity lives in hundreds of opaque dimensions.
  • No natural "no result." A nearest neighbor always exists, so semantic search returns something even when nothing in the corpus is relevant. You need a score threshold or a downstream check.
  • Model lock-in. Vectors from one embedding model can't be compared with vectors from another, so changing models means re-embedding the corpus.

Side by side


Keyword search (BM25)

Semantic search (dense vectors)

Matches on

Shared terms

Closeness in embedding space

Index

Inverted index (sparse)

ANN index such as HNSW or IVF (dense)

Strong at

IDs, error codes, names, legal and medical terms, exact phrases

Paraphrases, synonyms, vague or conversational questions

Weak at

Vocabulary mismatch ("lexical gap") [3]

Rare salient terms [2]; unfamiliar domains [3]

Explainability

High: per-term scores

Low

Needs an ML model

No

Yes, for indexing and every query

Tuning knobs

Analyzers, k1, b, field boosts

Model choice, chunking, ANN parameters

Zero results possible

Yes

Not without a threshold

Cost profile

CPU, inverted lists

Embedding compute plus vector memory

Illustrative examples

These examples show the typical failure pattern. They're for explanation, not measured results.

Query

Likely keyword result

Likely semantic result

"error E-4012 at checkout"

Finds the runbook that names E-4012

May return general checkout-failure pages ranked above the exact code

"how do I get my money back"

Misses a page titled "Refund policy" unless "money" or "back" appear

Finds "Refund policy"

"SOC 2 Type II report"

Finds documents with that exact phrase

Finds compliance pages, possibly mixing in unrelated audit reports

"laptop won't wake up after closing lid"

Hit or miss, depending on wording in the docs

Finds "sleep/resume issues" articles

The middle ground: learned sparse retrieval

The line between the two isn't as sharp as it was. Learned sparse models such as SPLADE use a neural network to produce sparse, term-weighted vectors. They keep "the exact matching of terms and the efficiency of inverted indexes" while learning to add related terms the document didn't literally contain [4]. Think of it as keyword search with a model-written thesaurus.

Late-interaction models such as ColBERT go the other way, keeping one vector per token for finer matching. Our guide to advanced document retrieval techniques covers them.

Why many systems use both

Because the two methods fail on different queries, running both and merging the results usually beats either alone on mixed workloads. That's hybrid search, and our explainer on hybrid search in enterprise RAG covers how Reciprocal Rank Fusion merges the lists. A reranking model can then reorder the merged list.

Vendors have converged on this. As of November 2026, Pinecone's documentation describes indexes that can serve BM25 full-text search, dense vectors and sparse vectors, with metadata filters [5]. Chroma's documentation lists dense, sparse and hybrid search alongside full-text and regex search [6]. We compare those products in FAISS vs Chroma vs Pinecone.

What it means for RAG

In retrieval-augmented generation, the retriever decides what the language model gets to read. A missed document is an answer the model can't give, or one it may make up. That shifts the trade-off:

  • Recall matters more than in classic search, because the model reads every chunk you pass it, not just the top link. A keyword-only system that misses paraphrased questions starves the model.
  • Exact terms matter more than demos suggest. Enterprise questions are full of SKUs, ticket numbers, product names and acronyms that embeddings can blur.
  • Chunking affects both. How you split documents changes what each method can match; see chunking strategies for RAG.

How to choose

Start from your queries, not from the technology.

  1. Pull 50 to 200 real queries from logs, tickets or user interviews. Label which documents should come back.
  2. Classify them. How many hinge on an exact identifier or phrase? How many are paraphrases or open-ended questions?
  3. Run both methods on the same set and measure with retrieval metrics such as Recall@K and MRR; our explainer on Precision@K, Recall@K and MRR shows how.
  4. Look at the failures, not just the averages. If keyword misses are paraphrases and semantic misses are identifiers, you need hybrid.

Rules of thumb:

  • Keyword-first fits catalogs, code search, log search, legal citations and anything where users type exact strings, or when you need to explain every result.
  • Semantic-first fits FAQ and help-center search, natural-language questions over prose, and cross-phrasing discovery.
  • Hybrid fits most enterprise RAG, where both kinds of query arrive at the same search box.

Outlook

The practical question has moved from "which one?" to "how much of each?" Learned sparse models blur the boundary [4], and mainstream vector products now ship keyword search inside the same index [5][6]. Expect the trade-off to show up in configuration (fusion weights, which fields get full-text indexing) rather than in a choice between products.

Frequently asked questions

Is semantic search always better than keyword search?

No. Benchmarks show dense retrievers winning on some datasets and losing on others; BEIR found BM25 a robust baseline across 18 datasets, with dense models often trailing on unfamiliar domains [3]. Test on your own queries.

What is BM25 in simple terms?

A formula that scores a document by how many of the query's words it contains, giving more weight to rare words, less to words repeated many times, and less to very long documents [1]. It's the standard ranking function behind keyword search.

Does semantic search understand what I mean?

It captures statistical similarity of meaning learned from training data, which handles synonyms and paraphrases well. It doesn't reason about your intent, and it can rank a confidently similar but wrong passage first.

Is vector search the same as semantic search?

In everyday use, yes: semantic search is usually implemented as vector search over embeddings. Strictly, vector search is the mechanism (nearest neighbors over vectors), and semantic search is the goal (matching on meaning).

Do I need a vector database for semantic search?

You need somewhere to store and search vectors. That can be a dedicated vector database, a search engine with vector support, or a library such as FAISS inside your app. Our vector database explainer covers the options.

Sources

  1. Robertson, S. and Zaragoza, H. "The Probabilistic Relevance Framework: BM25 and Beyond." Foundations and Trends in Information Retrieval 3(4), 2009. https://www.staff.city.ac.uk/~sbrp622/papers/foundations_bm25_review.pdf
  2. Karpukhin, V. et al. "Dense Passage Retrieval for Open-Domain Question Answering." arXiv:2004.04906, 2020. https://arxiv.org/abs/2004.04906
  3. Thakur, N. et al. "BEIR: A Heterogeneous Benchmark for Zero-shot Evaluation of Information Retrieval Models." arXiv:2104.08663, 2021. https://arxiv.org/abs/2104.08663
  4. Formal, T., Piwowarski, B. and Clinchant, S. "SPLADE: Sparse Lexical and Expansion Model for First Stage Ranking." arXiv:2107.05720, 2021. https://arxiv.org/abs/2107.05720
  5. Pinecone. "Indexing overview." Accessed November 2026. https://docs.pinecone.io/guides/index-data/indexing-overview
  6. Chroma. "Introduction." Accessed November 2026. https://docs.trychroma.com/docs/overview/introduction