Skip to main content
InterviewHubPRO
Section Overview
Q21

Question 21 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

42%
Elasticsearch & Lucene (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

How do Lucene Segments, Immutability, and Segment Merges work?

senior LevelelasticsearchAdvanced Internals

In Simple Words: A Lucene shard consists of multiple immutable files called Segments:

  • Immutability: Once written to disk, a segment is never modified. This allows segments to be cached in the OS file system cache without lock contention.
  • Deletes: When an item is deleted or updated, it is marked as deleted in a .del bitset file (soft delete); the old data remains on disk.
  • Segment Merging (TieredMergePolicy): A background process continuously merges smaller segments into larger ones, purging deleted documents and reclaiming disk space.