Web / Apache Lucene Interview questions
What is the purpose of the IndexWriter class?
IndexWriter is the class that creates and modifies a Lucene index - it's the only way to add, update, or delete Documents. Under the hood it buffers incoming Documents in memory and periodically flushes them to disk as new segments.
Key responsibilities include:
- Analyzing and adding new Documents.
- Deleting Documents by term or query.
- Coordinating background segment merges via a MergePolicy and MergeScheduler.
- Committing, which makes changes durable and visible to new readers.
Only one IndexWriter can hold the write lock on a given index directory at a time, which is why applications typically keep a single long-lived writer instance rather than opening a new one per request.
More Related questions...