Company
Date Published
Author
Adrien Grand
Word count
1257
Language
-
Hacker News points
None

Summary

Recent improvements in Elasticsearch have enhanced the efficiency of range queries, particularly when used in conjunctions with other queries. Traditionally, range queries faced challenges because they efficiently iterated over matches but struggled with verifying individual document matches due to the way numerics are indexed. By leveraging doc values, which provide a per-field lookup structure, Elasticsearch can now verify document matches more effectively. The introduction of a new mechanism, IndexOrDocValuesQuery, allows Elasticsearch to choose between using index structures or doc values based on whether the operation requires sequential access or random access. Benchmarks show significant performance improvements, especially for range queries intersecting with selective term queries, demonstrating a 30x speedup in some cases. Although the strategy is not flawless, as query planning is complex, these changes promise better query execution and have potential applications beyond range queries to include geo bounding-box and geo-distance queries. The enhancements are set to be included in Lucene 6.5 and Elasticsearch 5.4, suggesting future improvements for other query types that currently evaluate against the entire index.