# What is an inverted index?

> An inverted index lists, for each word, the documents that contain it. Keyword search engines use it to find matching documents without scanning every text.

Canonical: https://promptlyfound.com/glossary/inverted-index
Updated: 2026-12-01

## Short answer

An inverted index is **the data structure of keyword search: for each word, it lists the documents that contain it**. A search engine builds it before any query arrives. At query time, the engine looks up each query word and reads its list of documents, instead of scanning every text. Azure AI Search keeps one inverted index for each searchable field.

## Key findings

- Introduction to Information Retrieval calls the inverted index the first major concept in information retrieval. It says the structure is essentially without rivals as the most efficient way to support ad hoc text search. [1]
- Azure AI Search stores one inverted index for each searchable field. Each index holds a sorted list of all terms, and each term maps to the documents in which it occurs. [3]
- The dictionary of an inverted index records the document frequency of each term, the number of documents that contain it. Many ranked retrieval models use this statistic. [2]

An inverted index lets a search engine find every document that contains a word without reading the documents at query time. It is the index behind keyword search and the keyword side of AI retrieval.

## How does an inverted index work?

An inverted index has two parts: a dictionary of terms and, for each term, a list of the documents that contain it. [Introduction to Information Retrieval](https://nlp.stanford.edu/IR-book/html/htmledition/an-example-information-retrieval-problem-1.html), a Cambridge University Press textbook, calls each entry in a list a posting and each list a postings list. The dictionary is sorted alphabetically, and each postings list is sorted by document ID.[1]

Microsoft's page on [full text search in Azure AI Search](https://learn.microsoft.com/en-us/azure/search/search-lucene-query-architecture) gives an example. Four hotel documents have the titles "Hotel Atman", "Beach Resort", "Playa Hotel" and "Ocean Retreat". Part of the inverted index for the title field looks like this:[3]

```
atman    -> 1
beach    -> 2
hotel    -> 1, 3
ocean    -> 4
playa    -> 3
```

A query for "hotel" reads one line and gets documents 1 and 3. A phrase query such as "ocean view" looks up both terms and then checks how close together they appear in the document.[3]

## How is an inverted index built?

The engine builds the index before it answers queries. The textbook's section on [building an inverted index](https://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html) lists four steps: collect the documents, split each text into tokens, normalize the tokens into indexing terms, and record the documents that each term occurs in.[2] The core step sorts the pairs of term and document ID, merges duplicates, and splits the result into the dictionary and the postings.

The normalizing step decides what can match. Azure AI Search runs each text through an analyzer that lowercases it and strips punctuation, and it usually runs the same analyzer on queries.[3] The [Elastic documentation on text analysis](https://www.elastic.co/docs/manage-data/data-store/text-analysis) shows the limits. Without more analysis, "Quick" does not match "quick", "foxes" does not match "fox", and "jumps" does not match its synonym "leaps".[4]

## What role does the inverted index play in AI search?

The inverted index is the part of a retrieval system that finds exact words. Ranking functions such as [BM25](https://promptlyfound.com/glossary/bm25) score the documents it returns, using statistics such as the document frequency stored in the dictionary.[2]

Many AI retrieval systems pair it with a vector index in [hybrid search](https://promptlyfound.com/glossary/hybrid-search). Microsoft's [hybrid search overview](https://learn.microsoft.com/en-us/azure/search/hybrid-search-overview) says vector search can find similar content even when there are no keyword matches in the inverted index. Keyword search does better on exact matches such as product codes and people's names.[5]

A page enters an inverted index through the words it contains. A product name or a model number written in the text can match a query for it exactly. [What is semantic search?](https://promptlyfound.com/ai-search/semantic-search) explains how keyword search and search by meaning differ, and [How Google crawls and indexes pages](https://promptlyfound.com/crawlers/how-google-crawls-and-indexes) covers how pages get into Google's index.

## Sources

1. An example information retrieval problem. Introduction to Information Retrieval, Cambridge University Press. https://nlp.stanford.edu/IR-book/html/htmledition/an-example-information-retrieval-problem-1.html
2. A first take at building an inverted index. Introduction to Information Retrieval, Cambridge University Press. https://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html
3. Full text search in Azure AI Search. Microsoft Learn. https://learn.microsoft.com/en-us/azure/search/search-lucene-query-architecture
4. Text analysis. Elastic documentation. https://www.elastic.co/docs/manage-data/data-store/text-analysis
5. Hybrid search using vectors and full-text search in Azure AI Search. Microsoft Learn. https://learn.microsoft.com/en-us/azure/search/hybrid-search-overview

---

This is a plain-text copy of https://promptlyfound.com/glossary/inverted-index from Promptly Found. The web page is the canonical version and includes the charts.
