BooleanQuery rewrite for must_not RangeQuery clauses #17655
Draft
+342
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR automatically rewrites boolean queries which have a must_not RangeQuery clause to instead use a should clause of the complement of that range. This can be 2-10x faster depending on the query. See #17586 where this is described in more detail.
Example original query (on nyc_taxis):
Rewritten query:
Some benchmark numbers from http_logs and nyc_taxis (excluded ranges are on
@timestamp
anddropoff_datetime
fields respectively). "Originally written as" means whether the query was sent to OpenSearch with amust_not
clause, or if it was sent already rewritten withshould
clauses. Ideally, after the changes are applied, these p50s should be the same.I believe the small differences between runs (for example, 7/1-9/1
should
going from 427 -> 405 ms, when we'd expect no change) is just due to variation between different runs/instances. This is expected from what I've seen in tiered caching benchmarks. I've done a few runs and the direction/magnitude of the changes vary.Related Issues
Part of #17586
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.