liveBook · Manning

Inverted index

As explained in MongoDB 8.0 in Action, Third Edition

An inverted index is a search data structure that maps terms to the documents or positions in which they occur.

An inverted index maps searchable terms to the documents where they occur, allowing full-text search to retrieve matching content quickly instead of scanning every document. section 11.2 section 11.8

Apache Lucene builds this structure for full-text search. Before indexing, it tokenizes document content, can recognize multiword terms, and normalizes characters such as converting them to lowercase. Search results can then be ranked by relevance, with customization through boosting or score decay. section 11.2

Use an inverted index when search must go beyond exact database matching:

  • Retrieve relevant documents quickly across large collections. section 11.0
  • Support Boolean, fuzzy, wildcard, phrase, proximity, range, and faceted searches. section 11.0
  • Rank matches by term frequency and collection-wide term commonness, then tune results with custom scoring. section 11.2
  • Choose integrated Atlas Search when a separate search system would add synchronization, monitoring, and operational overhead. section 11.8

Inspection documents

For two inspection documents, the index associates tokens such as “BRONX,” “JERSEY CITY,” “NO VIOLATION ISSUED,” and “MOBILE FOOD VENDOR - 881” with the documents containing them. A query can therefore locate both records through shared terms and rank them by relevance. section 11.2

Table 11.1 Apache Lucene inverted index

Token

Document 1

Document 2

LISANDRO CABRERA

+

AZMY KIROLES

+

BRONX

+

JERSEY CITY

+

PALMER AVE

+

VROOM ST

+

10475

+

+

7306

2234

+

160

+

NO VIOLATION ISSUED

+

+

MOBILE FOOD VENDOR - 881

+

+

JUL 17 2015

+

DEC 23 2015

+

Browse the simplified Lucene inverted-index table linking inspection tokens to Documents 1 and 2. section 11.2

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Explains term mapping, tokenization, normalization, scoring, and query types, but stops short of index-construction internals.
Examples
Uses two inspection documents and a table mapping names, locations, dates, and inspection terms to matching documents.
What it assumes
Assumes basic documents and search queries while introducing tokenization, normalization, analyzers, and relevance scoring.
What you can do after
Evaluate/understand how Lucene and Atlas Search retrieve and rank documents through indexed terms.
How it connects
Connects inverted indexes with Apache Lucene, full-text search, tokenization, analyzers, relevance scoring, and Atlas Search.

Also explained in

Compare how 5 books explain inverted index →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.