Dataposting listposting listsfull-text index

Inverted index

Definition

An inverted index stores, for every term in a corpus, a posting list of the document ids (and often positions and frequencies) where the term occurs.

In practice

A query for "distributed cache" fetches two posting lists and intersects them, which takes milliseconds even over billions of documents. Engines such as Lucene, Elasticsearch and OpenSearch build immutable index segments, compress posting lists, and score matches with functions such as BM25. At web scale the index is sharded by document and every query fans out to all shards.

Updates are batched: new documents become searchable after the next segment refresh, so search is eventually consistent with the source database. Text analysis (tokenising, lower-casing, stemming) decides what matches, and changing it requires reindexing. Inverted indexes find words, not meaning, which is why many systems pair them with vector search.

Example

The term raft maps to documents [12, 87, 4031, ...], and consensus to [87, 512, 4031, ...]; intersecting them returns 87 and 4031 for the query "raft consensus".