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 |
|
|
+ |
|
|
|
+ |
|
|
|
+ |
|
|
|
+ |
|
|
|
+ |
|
|
|
+ |
|
|
|
+ |
+ |
|
|
||
|
|
+ |
|
|
|
+ |
|
|
|
+ |
+ |
|
|
+ |
+ |
|
|
+ |
|
|
|
+ |
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


