AlgoViz

Inverted indexes and postings

medium 4 min

An inverted index maps a term to ordered document identifiers.

Video lesson · Chapter 1 of 5

Three signs, two query words

0:00 / 3:43

Search three documents without opening them

1:10Reel

Theory

Read or listen first. About 1 min.

What it is

An inverted index turns the question around. Instead of examining each document for a term, it stores a sorted list of document IDs for each term.

Intersect two sorted posting lists

reset249token149Each list is sorted by document ID.
The dictionary maps reset to document IDs 2, 4 and 9. Token has its own ordered list, 1, 4 and 9.

Why it exists

Intersecting two much shorter lists can settle a conjunction without reading the document bodies. Phrase matching needs the additional evidence of term positions.

Words to know

Posting
An index entry linking a term to a document, optionally with frequency or position information.

How it works

Step through the idea, or press Play.

Step 1 of 3

Read postings. Reset gives 2, 4, 9. Token gives 1, 4, 9.

Understand it

Worked example

Inverted indexes and postings in practice

For reset in documents 2, 4, 9 and token in 1, 4, 9, an AND query intersects the postings to yield 4 and 9. Checking positions distinguishes the exact phrase from words scattered across a page.

Related case

Why did this document rank first?

An internal engineering search returns a long glossary above a precise two-paragraph runbook. Another user cannot find a document they just published.

The missing reset guide
Finding the reset guideRunbookjust writtenIndexold viewResultsno guideSearch has an older index view

Check refresh, terms and access filters.

Sources