Web / Apache Lucene Interview questions
Explain the internal working of Lucene's codec architecture?
A Codec defines exactly how every part of a segment is physically encoded on disk - postings lists, stored fields, term vectors, doc values, norms, and point (BKD tree) data each have their own file format, and the Codec is the pluggable component that determines those formats.
Lucene ships a default codec per release (for example, recent versions use a numbered codec like Lucene101Codec) that's tuned for the general case, but the architecture is deliberately pluggable: a custom Codec can swap in a different PostingsFormat, DocValuesFormat, or compression scheme for specialized needs, like a format optimized for extremely sparse fields.
PerFieldPostingsFormat and PerFieldDocValuesFormat extend this further, letting different fields within the same segment use entirely different underlying encodings - so a high-cardinality identifier field and a full-text prose field can each get storage tuned to their own access pattern within one index.
More Related questions...