Inferensys

Glossary

Inverted Index

A data structure that maps each unique term to a postings list of document identifiers where the term appears, enabling efficient Boolean and ranked keyword search.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
SPARSE RETRIEVAL DATA STRUCTURE

What is an Inverted Index?

An inverted index is a fundamental data structure in information retrieval that maps each unique term to a postings list containing the identifiers of all documents where that term appears, enabling efficient Boolean and ranked keyword search.

An inverted index is a hash map-like structure that inverts the relationship between documents and terms. Instead of a forward index listing terms per document, it creates a dictionary of every unique token across a corpus. Each dictionary entry points to a postings list—a sorted sequence of document IDs where the term occurs, often accompanied by metadata like term frequency and positional offsets for phrase queries.

During query execution, the index enables sub-linear retrieval by intersecting postings lists for multi-term queries. This structure powers the BM25 ranking function and remains the backbone of sparse lexical retrieval in modern hybrid search architectures, where it complements dense vector search to ensure exact keyword matching and high precision for rare terms.

ANATOMY OF AN INVERTED INDEX

Core Characteristics

The inverted index is the foundational data structure enabling sub-second keyword search across billion-document corpora. It maps terms to their locations, inverting the document-centric view into a term-centric lookup.

01

The Dictionary and Postings

An inverted index consists of two core components: the dictionary (or lexicon) and the postings lists. The dictionary is a sorted list of all unique terms found in the document collection. For each term, a pointer references a postings list—a sequence of document IDs where that term appears. This structure allows a query processor to look up a term in the dictionary in O(log n) time and immediately retrieve the complete list of matching documents without scanning the corpus.

O(log n)
Dictionary Lookup Time
02

Term Frequency and Positional Data

Postings lists rarely store just document IDs. To enable ranked retrieval, each posting typically includes term frequency (TF)—the count of term occurrences within a document. For phrase queries and proximity search, positional indexes store the exact byte or word offsets of each occurrence. This granularity allows the engine to confirm that the terms 'machine' and 'learning' appear adjacently, not just in the same document, rejecting false positives.

TF + Positions
Standard Posting Payload
03

Skip Pointers for Query Acceleration

To speed up the intersection of two large postings lists during Boolean AND queries, indexes often embed skip pointers. These are strategic jumps within a postings list that allow the traversal algorithm to skip over large blocks of document IDs that cannot possibly appear in the intersection result. By skipping to the next document ID that is greater than or equal to the current candidate, the algorithm avoids a linear scan, reducing merge complexity.

√L
Optimal Skip Interval (List Length L)
04

Delta Encoding and Compression

Postings lists are highly compressible. Since document IDs are stored in ascending order, they are typically converted to delta gaps—the difference between consecutive IDs. Small gaps are then encoded using variable-length byte schemes like VByte or bit-aligned codes. This compression drastically reduces the index's memory footprint and I/O cost, allowing large portions of the index to reside in RAM for maximum performance.

~75%
Typical Size Reduction
05

Static vs. Dynamic Indexing

Index construction strategies fall into two categories. Static indexing builds the entire index offline in a batch process, optimizing for compactness and query speed. Dynamic indexing supports real-time updates by maintaining a small in-memory index for new documents, periodically merging it with the larger on-disk index. This log-structured merge-tree approach is critical for applications requiring immediate searchability of fresh content.

Near Real-Time
Dynamic Update Latency
06

Tokenization and Preprocessing

Before terms enter the dictionary, raw text undergoes a preprocessing pipeline. Tokenization splits text into discrete tokens. Case folding normalizes all characters to lowercase. Stemming (e.g., Porter stemmer) or lemmatization reduces words to their root form, mapping 'running' and 'runs' to 'run'. Stop word removal eliminates high-frequency, low-signal terms like 'the' and 'is'. These steps must be applied identically to both documents and queries.

Recall vs. Precision
Core Preprocessing Trade-off
INVERTED INDEX

Frequently Asked Questions

Explore the mechanics, performance characteristics, and architectural role of the inverted index—the foundational data structure powering sparse lexical retrieval in modern hybrid search systems.

An inverted index is a data structure that maps each unique term in a document corpus to a postings list—a sorted list of document identifiers where that term appears. Unlike a forward index that maps documents to terms, the inverted index reverses this relationship to enable efficient full-text search. During indexing, documents are tokenized, normalized, and stemmed. For each term, the system records the document ID, term frequency, and positional offsets. At query time, the index retrieves postings lists for query terms and performs Boolean intersection or union operations to identify matching documents. This structure allows search engines to locate relevant documents without scanning the entire corpus, reducing search complexity from O(N) to O(1) for term lookup plus the cost of merging postings lists.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.