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

Summary

Elasticsearch 2.0 introduces significant internal changes to improve query execution by merging queries and filters into a single object that can score documents or skip scoring, thus optimizing performance and consistency. This update, largely influenced by changes in Lucene 5.0 to 5.2, deprecates the filtered query in favor of a new filter clause and unifies conjunctions into the bool query, allowing for robust optimizations through two-phase execution. The two-phase iteration pattern enables better handling of complex queries, such as geo-distance and phrase queries, by separating approximation and verification phases to enhance efficiency. Additionally, Elasticsearch 2.0 implements smarter, automatic filter caching to avoid over-caching, prioritizing the reuse of filters and introducing sparse bit sets to make filter caching more memory-efficient. Multi-term queries can now be rewritten into bool queries when matching few terms, improving intersection efficiency, while span queries benefit from the two-phase iteration, with new span-within and span-containing queries enhancing their capabilities. These advancements collectively enable Elasticsearch to autonomously optimize query execution without requiring manual adjustments from users.