Web / Apache Lucene Interview questions
Define a Lucene Segment?
A segment is a self-contained, immutable mini-index. A full Lucene index is just a collection of segments plus a small commit file listing which ones are current.
Every time IndexWriter flushes buffered documents, it writes a brand-new segment rather than editing an existing one - segments, once written, are never modified in place. Deletes are handled with a separate "live docs" bitset marking which documents in a segment are still visible, rather than rewriting the segment itself.
Over time, small segments accumulate and get combined by background merges into fewer, larger segments, which keeps search fast and reclaims space from deleted documents.
More Related questions...