Tutorial
Arslan
ArslanOct 17, 2026

Learn what information retrieval is, how search systems rank results, and how BM25, vector search, hybrid retrieval and RAG improve search relevance.

What Is Information Retrieval? How Search Finds What You Need

Information retrieval (IR) is the process of finding the documents or passages in a large collection that best satisfy an information need. It then ranks them by relevance. You type a query, the system matches it against an index, and it returns a ranked list of the most useful results.

The standard academic definition comes from the Stanford IR textbook by Manning, Raghavan and Schütze: "Information retrieval (IR) is finding material (usually documents) of an unstructured nature (usually text) that satisfies an information need from within large collections (usually stored on computers)." In everyday use, "search" and "information retrieval" mean almost the same thing.

A few terms come up again and again:

  • Information need: the thing you actually want to know, such as how to reset a router.
  • Query: the words you give the system to express that need.
  • Document: any unit the system can return, such as a web page, a PDF or a text chunk.
  • Collection (corpus): the full set of documents the system can search.
  • Relevance: how well a document satisfies the information need, not just whether it contains the query words.

How Does Information Retrieval Work?

An IR system works in five stages: acquire documents, represent them, index them, match and rank them against a query, and evaluate the results. Each stage depends on the one before it.

Many guides start at indexing. For systems built on web data, retrieval quality starts earlier, with how the collection is gathered and cleaned.

Step 1: Acquire the Document Collection

A system can only retrieve what it has collected. For a library, that means cataloged books. For a search engine or AI application, it means pages fetched from the web.

Web acquisition has two parts. Discovery finds the URLs, using sitemaps and links, and tools such as URL discovery with Maps return the URLs on a site. Fetching then downloads each page, and crawling a whole site collects many pages in one job. Responsible acquisition respects robots directives, site terms and rate limits. JavaScript-heavy pages may also need browser rendering before their final content can be extracted.

Step 2: Clean and Represent Each Document

Raw HTML is noisy. Menus, cookie banners, ads and scripts sit next to the content you actually want to retrieve. If that noise gets indexed, it can match queries it has nothing to do with.

Extracting the main content into LLM-ready web data formats such as Markdown or JSON gives the indexer cleaner text. It also gives a language model fewer wasted tokens. The system then prepares the text:

  • Tokenization: splits text into words or sub-word units.
  • Normalization: lowercases text and removes punctuation.
  • Stemming or lemmatization: reduces words to a base form, so "routers" matches "router".
  • Chunking: splits long documents into passages, which RAG systems need.

Step 3: Build an Index

An index is a data structure that makes search fast. The classic version is the inverted index. It maps each term to a posting list, which records every document containing that term. An inverted index works like the index at the back of a book.

Modern systems often add a vector index, which stores numeric embeddings and finds the nearest ones to a query. Approximate nearest neighbor (ANN) methods such as HNSW keep vector search fast at scale. Indexes can get very large: Google's Search index "covers hundreds of billions of web pages and is well over 100,000,000 gigabytes in size," according to Google.

Step 4: Process the Query and Rank Results

The system processes the query the same way it processed the documents, using the same tokens and stems. It pulls candidate documents from the index, and a ranking function then scores each candidate and returns the top results (the "top-k").

Simple systems rank by text relevance alone. Web search layers many signals, including BM25-style term scoring, link analysis such as PageRank, and neural language matching. Olostep's glossary covers these ranking algorithms in web search in more detail.

Step 5: Evaluate and Improve

Evaluation compares the system's results against relevance judgments, which are human or model labels saying which documents are actually relevant. The scores show where the system misses.

Common improvements include relevance feedback, where clicks or labels re-weight the query, and query expansion, which adds synonyms or related terms. Large language models (LLMs) now often rewrite queries too.

What Are the Main Information Retrieval Models?

The three classic types of information retrieval models are Boolean, vector space and probabilistic. Modern systems add dense (neural) retrieval and hybrid retrieval, which combines keyword and neural methods.

ModelHow It MatchesMain StrengthMain WeaknessTypical Use
BooleanExact rules with AND, OR, NOTPrecise, predictableNo ranking; strict syntaxLegal and patent search, filters
Vector space (TF-IDF)Weighted term vectors, cosine similarityRanks by partial matchMisses synonymsClassic text search
Probabilistic (BM25)Estimated probability of relevanceStrong, fast baselineMisses paraphrasesDefault in many search engines
Dense retrievalNeural embeddings, nearest neighborsMatches meaningCan miss exact IDs and rare termsSemantic search, RAG
HybridFuses keyword and dense resultsCovers both failure modesMore components to tuneProduction RAG and search

Boolean Retrieval Model

The Boolean model treats a query as a logical rule. A query such as router AND password NOT email returns every document that satisfies the rule and nothing else.

Results form a set, not a ranked list, so a document either matches or it does not. Boolean logic still powers legal and patent search, and it powers the metadata filters in many search tools.

Vector Space Model and TF-IDF

The vector space model represents each document and query as a vector of term weights. It then ranks documents by how closely their vectors point in the same direction, using cosine similarity.

TF-IDF is the usual weighting scheme. Term frequency (TF) rewards words that appear often in a document. Inverse document frequency (IDF) rewards words that are rare across the collection. TF-IDF vectors are sparse word counts, not learned embeddings. The two are often confused.

Probabilistic Model and BM25

The probabilistic model ranks documents by their estimated probability of being relevant to the query. BM25 (Best Matching 25) is its best-known scoring function and the default ranking function in Lucene-based engines such as Elasticsearch.

BM25 improves on raw TF-IDF with two controls:

  • k1 (term saturation): limits how much repeated words add, so the tenth mention of "router" counts far less than the first.
  • b (length normalization): stops long documents from winning just because they contain more words.

Dense, Sparse and Hybrid Retrieval

Dense retrieval converts queries and documents into neural embeddings and matches them by meaning. This approach is often called semantic search or vector search. Sparse retrieval, such as BM25, matches exact terms. Hybrid search runs both and merges the ranked lists, often with Reciprocal Rank Fusion (RRF).

Dense retrieval does not automatically win. On financial text-and-table documents, a 2026 retrieval benchmark (an arXiv preprint) reported Recall@5 of 0.644 for BM25 and 0.587 for dense retrieval. Hybrid RRF scored 0.695, and hybrid plus a reranker reached 0.816. The authors note that results may not carry over beyond finance. Treat BM25 as a strong baseline, and measure every upgrade against it.

An Information Retrieval Example, Step by Step

Here is a small example that shows ranking and evaluation together. The collection has four documents, and the query is "reset router password".

DocTextQuery Terms Matched (After Stemming)Relevant?
D1How to reset your router passwordreset, router, passwordYes
D2Factory reset steps for Wi-Fi routersreset, routerYes
D3Reset a forgotten email passwordreset, passwordNo
D4Best password managers in 2026passwordNo

D1 matches all three terms, so it ranks first. D2 and D3 each match two terms, but "router" appears in only 2 of 4 documents while "password" appears in 3. The rarer term carries more weight, so D2 ranks above D3. The final order is D1, D2, D3, D4.

Now score the top three results. Two of the three are relevant, so precision@3 is 2/3, or 0.67. Both relevant documents appear in the top three, so recall@3 is 2/2, or 1.0.

Stemming changes the outcome. Without it, "routers" in D2 does not match "router", so D2 drops below D3. Precision@2 then falls from 1.0 to 0.5. This is a small example of why representation choices in Step 2 shape ranking in Step 4.

The same pattern applies to the live web. This request sends a query to Olostep's Searches endpoint and prints the ranked links it returns:

python
import requests

resp = requests.post(
    "https://api.olostep.com/v1/searches",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"query": "reset router password", "limit": 5},
)

for link in resp.json()["result"]["links"]:
    print(link["url"], "-", link["title"])

Information Retrieval vs. Data Retrieval

Information retrieval finds relevant unstructured content and ranks it. Data retrieval fetches exact records from structured data. A SQL query that returns every order over $100 is data retrieval. A search for "laptop that stays cool" is information retrieval.

DimensionInformation RetrievalData Retrieval
Data typeUnstructured text, pages, mediaStructured rows and fields
QueryNatural language or keywordsFormal language such as SQL
MatchingPartial, by relevanceExact, by rule
ResultRanked listComplete set
Error toleranceSome irrelevant results expectedOne wrong record is a bug
ExampleWeb search, RAGDatabase lookups

In practice, the line is blurry. Production search often combines ranked text retrieval with exact metadata filters such as date, language or domain.

How Is Retrieval Quality Measured?

Retrieval quality is measured by comparing results to relevance judgments. Precision is the share of retrieved results that are relevant. Recall is the share of all relevant documents that were retrieved.

MetricWhat It MeasuresUse It When
PrecisionShare of retrieved results that are relevantWrong results are costly
RecallShare of relevant documents that were foundMissing documents is costly
Precision@kPrecision within the top k resultsUsers or LLMs read only the top results
Recall@kRecall within the top k resultsChecking RAG context windows
MRRHow high the first relevant result ranksOne right answer is enough
nDCGRanking quality with graded relevanceOrder and degree of relevance both matter

Public test collections such as TREC, MS MARCO and BEIR let teams compare methods. For a real application, build a small golden set. Collect real queries from your users, label the relevant documents, and re-run the set after every change to chunking, embeddings or ranking.

Information Retrieval for RAG and AI Agents

An LLM's built-in knowledge stops at its training data. Information retrieval supplies the current, specific context they lack, which makes IR the foundation of retrieval-augmented generation and of AI agents that use the web.

How Retrieval-Augmented Generation Uses IR

Retrieval-augmented generation (RAG) retrieves relevant passages, places them in the model's prompt, and generates an answer grounded in those passages. Systems such as Olostep's source-grounded answers endpoint combine web retrieval with generation and return answers with their sources.

The answer is usually only as good as the retrieved context. Better retrieval does not remove every error, though. In a peer-reviewed RAG study, hybrid retrieval raised accuracy for LLaMA3.1-8B from 37.92% to 46.29%. The authors also found that "hybrid retrieval introduces a trade-off between accuracy and faithfulness." Evaluate both whether answers are correct and whether they stay faithful to the sources.

Why AI Agents Are the Web's Second User

AI crawlers and agents are a growing class of web user, alongside people. According to Cloudflare's 2025 Radar review, "traffic from AI bots accounted for an average of 4.2% of HTML requests" on sites behind Cloudflare in 2025. That figure covers AI crawlers and agents combined.

Agents retrieve differently from people. They issue many short, machine-written queries in loops, refine them based on what they find, and need structured, citable output within latency and token budgets. Olostep's guide explains how agentic search works in that loop.

Static Index vs. Live Web Retrieval

A static index is a collection you crawl and store ahead of time. Live retrieval searches and fetches the web at query time. Many production systems use both.

FactorStatic IndexLive Web Retrieval
FreshnessAs fresh as the last crawlCurrent at query time
LatencyLow; lookup is localHigher; pages are fetched on demand
Cost profileUpfront crawl and storagePer-query search and fetch
ControlFull control over chunking and rankingDepends on search and fetch quality
Best fitStable docs, internal knowledgeNews, prices, fast-changing pages

Freshness is a retrieval problem, not just a storage problem. A perfectly ranked page with outdated information can still produce a wrong answer. Store timestamps with every document, re-crawl on a schedule that matches how often sources change, and use monitoring pages for changes to update the index when content moves.

Why Information Retrieval Fails in Practice

Many retrieval failures start upstream, in the data rather than the ranking model. Use this table to diagnose common problems.

SymptomLikely CauseFix
Relevant docs use different words than the queryVocabulary mismatchAdd dense retrieval or query expansion
Exact product codes or names are missedEmbeddings blur rare tokensAdd BM25 to make retrieval hybrid
Results match menus or footersNoisy HTML extractionExtract main content to Markdown
Answers miss key contextChunks split ideas apartChunk by headings; add overlap
Answers cite outdated factsStale indexTrack timestamps; monitor and re-crawl
Results from the wrong region or dateNo metadata filtersStore and filter on metadata

Adding hybrid search can barely change results on some datasets. The gain depends on the query mix and the chunk quality. Test every change against your golden set before you ship it.

Where Information Retrieval Is Used

Information retrieval powers products that need to find relevant content in a large collection. Web search is the largest example: Google reports more than 5 trillion searches per year. In Google's words, "We already see more than 5 trillion searches on Google annually."

Other common applications include:

  • Enterprise search: finding internal documents, tickets and wikis.
  • E-commerce search: matching shopper queries to products.
  • Legal and patent search: high-recall searches across case law and filings.
  • Digital libraries: searching academic papers and archives.
  • RAG assistants and AI agents: retrieving live context before generating answers.

A Short History of Information Retrieval

Information retrieval grew from library science into one of computing's core fields.

  • 1945: Vannevar Bush describes the memex, an imagined machine for linking and retrieving records.
  • Around 1950: Calvin Mooers coins the term "information retrieval".
  • 1960s: Gerard Salton's SMART system introduces the vector space model.
  • 1970s: Karen Spärck Jones and Stephen Robertson develop inverse document frequency and probabilistic retrieval.
  • 1992: The first Text REtrieval Conference (TREC) creates shared test collections.
  • 1990s: BM25 emerges from the Okapi system and becomes a standard baseline.
  • 1998: PageRank brings link analysis to web search.
  • Around 2019–2020: Neural models such as BERT bring dense retrieval into mainstream use.
  • 2020: Retrieval-augmented generation connects retrieval directly to language models.

FAQ

What Are the Three Types of Information Retrieval?

The three classic information retrieval models are Boolean, vector space and probabilistic. Modern systems add dense neural retrieval and hybrid retrieval.

Mostly, yes. "Search" is the everyday word for information retrieval, while IR is the field that studies how search systems find and rank content.

Is Information Retrieval Part of AI or NLP?

Information retrieval is its own field of computer science that overlaps heavily with natural language processing and machine learning. Modern IR often uses neural language models for ranking and retrieval.

What Is an Example of an Information Retrieval System?

Web search engines, library catalogs, e-commerce site search and RAG chatbots are all information retrieval systems. Each one matches queries against an index and returns ranked results.

BM25 ranks documents by exact term matches weighted by rarity and frequency. Vector search ranks documents by the similarity of their neural embeddings, so it can match meaning even when the words differ.

Do Long Context Windows Replace Retrieval?

Usually not. Even large context windows have cost, latency and size limits, so a system still needs retrieval to choose which current, relevant content goes into the prompt.

How Do You Keep a Retrieval Index Fresh?

Store a timestamp with every document, re-crawl sources on a schedule that matches how often they change, and use change monitoring to update pages after they change.
to update pages after they change.

About the Author

Arslan Ali

Co-Founder, Olostep · San Francisco, CA

Arslan is the co-founder of Olostep, a web data infrastructure platform that helps developers and teams access, extract, and structure web data at scale. He works closely on the product and technology behind Olostep, with a focus on building reliable infrastructure for web scraping, search APIs, and structured web data.

Read more