For agents: Read llms.txt for the complete documentation and public content index. Request this page as Markdown.

Skip to main content
Ceisium logo Ceisium
A term dictionary sends one highlighted term through posting lists to matching document nodes.
A term dictionary sends one highlighted term through posting lists to matching document nodes.

A term dictionary sends one highlighted term through posting lists to matching document nodes.

What Is an Inverted Index?

An inverted index maps terms to the documents that contain them, helping search engines find text matches without scanning every page.

A user searches a help site for:

TEXT
reset password

The site has four pages. In this example, the search system indexes both the page title and the text below it.

IDPage titleText
P1Manage your accountManage your account and password.
P2Reset a forgotten passwordReset a forgotten password.
P3Billing helpDownload invoices and update payment details.
P4Protect your accountProtect your account with two-factor authentication.

The system could open all four pages and check every word. That works here, but repeating the scan for every query becomes wasteful as the collection grows.

Instead, it prepares a lookup before the user searches. That lookup is an inverted index.

What is an inverted index?

An inverted index maps each searchable term to the documents that contain it.

For our four pages, part of the index looks like this:

TEXT
account        -> P1, P4password       -> P1, P2reset          -> P2payment        -> P3authentication -> P4

This is similar to the index at the back of a book. You start with a topic and get the pages where it appears.

The mapping is called inverted because it reverses the direction we begin with. The original content starts as pages containing words. Search needs words pointing to pages .

The set of searchable terms is often called the vocabulary or lexicon. A term dictionary organizes those terms and points to their postings lists.

The list beside each term is a postings list. The postings list for password is P1, P2. Each document entry inside that list is one posting.

The direction changes: pages contain terms, but the search lookup starts with a term and follows it to page IDs.
Black llama-head blob turning four page cards into a vocabulary whose terms point to P1 and P2 postings.

The direction changes: pages contain terms, but the search lookup starts with a term and follows it to page IDs.

How is an inverted index built?

The system first extracts the text it wants to make searchable. It then breaks that text into smaller units called tokens.

For example:

TEXT
"Reset a Forgotten Password"

may become:

TEXT
reset, a, forgotten, password

The system may also make text lowercase or handle punctuation. These choices make document terms and later query terms compatible. The exact processing varies by implementation.

Each final term is added to the postings for the field being indexed. Some systems keep separate term dictionaries and postings for fields such as titles and bodies.

How does search use the index?

Now the user searches for:

TEXT
reset password

The search system analyzes the query into terms compatible with those stored in the index:

TEXT
[reset, password]

Then it reads the two postings lists:

TEXT
reset    -> P2password -> P1, P2

P2 appears in both lists, so it contains both query terms. P1 appears only in the password list, so it is a partial match. Whether P1 is retained depends on whether the search requires every term or allows partial matches.

The shared part of the lists is their intersection. For this query, the intersection is just P2.

The engine can start with these short term-led lists instead of reopening every page to discover possible matches. Those possible matches are the candidates that a ranking method can order.

P2 appears in both postings lists. It survives the intersection, while P1 is only a partial match.
Black llama-head blob pulling reset and password posting strips through a clamp that keeps shared page P2 and leaves P1 as a partial match.

P2 appears in both postings lists. It survives the intersection, while P1 is only a partial match.

Does an inverted index rank the results?

The index retrieves candidates and can store clues about them. A posting may include how often the term appeared and where it appeared among the other tokens. The system may also keep separate postings for the title and body.

In our example, P2 contains both query terms, and both appear in its title. P1 contains only password. A ranking formula can use those differences to give P2 a stronger score.

Ranking turns those clues into an order. The index retrieves possible matches and stored clues. The ranker decides their order.

Methods such as BM25 rank word-based matches using term evidence. The inverted index makes that evidence available; the ranking method decides how much each clue matters.

Stored token positions can also support phrase or nearby-word search. P2 is not an exact-phrase match for reset password because another word sits between the two terms. A hypothetical page containing the exact phrase could be treated differently from one where the words appear paragraphs apart. Not every index stores positions, so this behavior depends on the system.

What happens when a page changes?

Suppose P1’s title and text both change:

TEXT
Title: Manage your accountText:  Manage your account and password.

becomes:

TEXT
Title: Profile and login settingsText:  Update your profile and login settings.

Conceptually, selected affected postings change like this:

TEXT
account  -> remove P1password -> remove P1profile  -> add P1login    -> add P1settings -> add P1

This does not mean every engine edits one list in place. An implementation may write new index segments, mark old entries as deleted, merge segments later, or rebuild on a schedule. The useful reader model is simpler: P1 must stop appearing under its old terms and start appearing under its new ones.

A single edit does not always require rebuilding the complete index. Search can still lag behind the source content when updates are delayed or batched.

The targeted lookup has a cost. The index takes storage and work to build and maintain, and new content must reach it before search can use it.

The index is a maintained lookup over the source content, not the source content itself. The source page can change before its searchable representation is refreshed.

What does an inverted index not solve?

A basic inverted index is strong at finding exact or normalized word-based terms. It does not automatically understand every way a person can describe the same need.

A user may search for:

TEXT
forgot my login

while the useful page says:

TEXT
Reset your password

Those phrases share little vocabulary. Synonym handling, spelling correction, query expansion, or vector search can help with differently worded meaning. An inverted index does not add those choices automatically.

Word-based matching still matters for product names, API routes, error codes, and exact technical terms. A search system can combine more than one retrieval method when its query mix needs both literal and semantic evidence.

Inverted index summary

An inverted index keeps a postings list for each searchable term.

The basic flow is:

TEXT
indexed fields -> searchable terms -> postings listsquery          -> compatible terms -> matching postings

It makes candidate lookup targeted. Optional stored clues can support ranking and phrase behavior, while update work keeps the lookup fresh.

Start with the term, then follow it to the documents.

Next reads