Elasticsearch & Lucene (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Doc Values vs Fielddata: Memory tradeoffs, column-oriented storage, and sorting/aggregations architecture.
senior LevelMost AskedSystem DesignAlgorithms
In Simple Words: The inverted index is optimized for search ("find documents matching 'kubernetes'"), but terrible for sorting or aggregations ("group by category and calculate average price"):
- Doc Values: On-disk, column-oriented data structure built at index time for non-analyzed fields (
keyword,numeric,date). Uses the OS Page Cache, preventing JVM Heap bloat and OOM crashes. - Fielddata: In-memory data structure built dynamically on first query for analyzed
textfields. High memory usage; dangerous in production without strict circuit breakers.