Web / Apache Lucene Interview questions
How do you optimize a Lucene index for search performance?
Search performance tuning in Lucene usually comes down to a handful of high-leverage decisions rather than one silver bullet:
- Choose field types deliberately - use DocValues fields for sorting/faceting instead of loading stored values at query time.
- Disable norms/term vectors on fields where scoring precision or highlighting isn't needed, to save memory.
- Use Points fields (IntPoint, LongPoint) for numeric range filters rather than string-based range queries.
- Tune the MergePolicy so segment count stays reasonable without excessive merge I/O.
- Warm searchers after reopening so caches (like DocValues) aren't cold on the first real query.
- Favor filters over scored queries for non-relevance criteria, since filters can be cached and skip scoring work.
Profiling with actual production-shaped queries before and after each change matters more than applying every tuning option blindly - some of these trade indexing speed or memory for query speed, so the right mix depends on the workload.
More Related questions...