What is keyword search?

Keyword search is the classic search method that returns documents by checking whether query words appear in them exactly or in normalised form, ranking results by how frequent and distinctive those words are.

Unlike semantic search, which finds text close in meaning even when worded differently, keyword search looks for the word itself, making it more reliable for exact-match queries such as product codes, contract numbers or proper names. BM25 is its most widely used scoring method.

Topic
Embeddings, document processing and RAG
Also known as
Lexical search, full-text search

How keyword search works

  1. Documents are split into words and normalised; in heavily inflected languages stemming or similar processing matters for matching word forms.
  2. An inverted index is built, recording which documents contain each word.
  3. The query is processed the same way and matching documents are found in the index.
  4. Documents are ranked by measures such as term frequency, how rare the term is in the collection and document length.

In more detail

BM25 scoring dynamics: term frequency saturation and length normalisation

In BM25, a term's contribution saturates as its frequency within a document grows (controlled by hyperparameter k1), preventing keyword stuffing from dominating results, while document length normalisation (controlled by b) ensures long reports do not unfairly crowd out concise matches.

Score fusion in hybrid search

In hybrid RAG pipelines, keyword (BM25) scores and dense vector similarity scores operate on incompatible scales. Systems typically merge both ranked lists using Reciprocal Rank Fusion (RRF) or min-max score normalisation before passing top chunks to a cross-encoder reranker.

Turkish stemming and the code tokenisation trap

Because product codes, part numbers (e.g., 'AB-1042/X') and Turkish agglutinative suffixes can be mangled by standard whitespace tokenisers or aggressive stemming, enterprise indexes pair custom regex/character-ngram tokenisers with morphological lemmatisation rather than naive suffix stripping.

Commonly confused terms

TermHow it differs
Learned sparse retrievalLearned sparse retrieval (such as SPLADE or BGE-M3 sparse) uses a neural model to expand and weight lexical terms into sparse vectors, whereas traditional keyword search relies purely on statistical formulas like BM25 without neural inference.
Substring or pattern matchingSimple substring matching (like SQL LIKE or grep) checks raw character sequences without tokenisation, normalisation or relevance scoring, whereas keyword search uses inverted indexes and ranking algorithms such as BM25.

Why keyword search matters for on-premises AI

In in-house retrieval-augmented generation keyword search catches exact terms that embedding-based search can miss, so most systems combine both in hybrid search. It runs fast on CPUs without GPUs, works with a local index in air-gapped environments and lets document-level permission filters apply at query time. Results are also easier to explain, since matching words are visible.

ON-PREMISES EXAMPLE

A defence company's technical documentation assistant uses a hybrid setup favouring keyword search for questions with part numbers and semantic search for questions like how maintenance intervals are set, so queries with codes reach the right document.

Common questions

How does keyword search differ from semantic search?

Keyword search checks whether words appear in a document. Semantic search looks at similarity of meaning and can find text worded differently.

Is keyword search still needed in RAG?

Yes. It is more reliable than embedding-based search for exact-match queries such as codes, numbers and names, so most systems use both.

Sources

In the glossary: Glossary, E to L

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.