Inverted index (source code)

= Inverted index

An <inverted index> maps each indexing term to the documents containing it. A term dictionary provides access to a <postings list>; each posting records a document identifier, sometimes with additional information such as occurrence positions. A <positional index> retains those positions for queries involving word order.<Introduction to Information Retrieval by Christopher D. Manning and others>[§1.1, Figure 1.3 and the dictionary/postings explanation]{ref}

Consider documents one `red boat`, two `blue boat` and three `red train`. The <postings list> for `red` is `1,3`, and that for `boat` is `1,2`. Intersecting them answers `red AND boat` with document one, without scanning every document's complete text at query time. Sorting document identifiers permits a coordinated traversal of both lists. Preprocessing decisions still matter: an <inverted index> for case-folded terms answers a different matching question from one preserving exact capitalization. The <data structure> accelerates access; it does not itself establish relevance.