liveBook · Manning

Lucene

As explained in MongoDB 8.0 in Action, Third Edition

Apache Lucene is an open-source Java information-retrieval library that provides indexing and search capabilities for text and other data.

Apache Lucene is an open-source information-retrieval library, initially written in Java, that indexes and searches text and other document types. It supports applications ranging from web platforms to personal desktops and underpins systems such as Solr and Elasticsearch. section 11.2

Lucene’s core structure is an inverted index: instead of mapping pages to words, it maps searchable tokens to the documents containing them. This enables fast retrieval across fields such as names, locations, dates, and inspection results. section 11.2

Lucene prepares and ranks search data through several related operations:

  • Tokenizes document text into smaller searchable units, typically using delimiters such as spaces. section 11.2
  • Uses dictionaries to support multiword terms, phrases, and specialized terminology. section 11.2
  • Normalizes tokens by converting characters to lowercase, producing more uniform matches. section 11.2
  • Assigns relevance scores, favoring frequent query terms while discounting terms common across the collection. section 11.2
  • Customizes ranking with boosting or score decay when a search domain needs different relevance behavior. section 11.2

Inspection records

Two inspection documents containing the result “No Violation Issued” and the sector “Mobile Food Vendor - 881” produce shared index entries for those terms. Distinct names, cities, addresses, dates, and numbers receive document-specific entries, allowing queries to retrieve and rank matching records. 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

+

Inspect the simplified inverted index linking tokens such as names, cities, results, sectors, and dates to the two example documents. section 11.2

In local Atlas deployments, the mongot process wraps Apache Lucene and handles full-text and vector search. It monitors MongoDB change streams, updates Lucene indexes in real time, and exposes an API for querying them through MongoDB. section 13.1

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Explains inverted indexes, tokenization, normalization, scoring, and mongot synchronization, but not Lucene API implementation.
Examples
Uses two inspection documents and a simplified token-to-document index covering names, locations, results, sectors, dates, and numbers.
What you can do after
Evaluate how tokenization, inverted indexes, and scoring support fast full-text retrieval and domain-specific ranking.
How it connects
Connects inverted indexes, tokenization, normalization, relevance scoring, MongoDB change streams, and vector search.

Also explained in

Compare how 3 books explain Lucene →

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.