-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Handle IndexOrDocValuesQuery in composite aggregation #35392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle IndexOrDocValuesQuery in composite aggregation #35392
Conversation
The `composite` aggregation can optimize its execution when the query is a `match_all` or a `range` over the field that is used in the first source of the aggregation. However we only check for instances of `PointRangeQuery` whereas the range query builder creates an `IndexOrDocValuesQuery`. This means that today the optimization does not apply to `range` query even if the code could handle it. This change fixes this issue by extracting the index query inside `IndexOrDocValuesQuery`.
Pinging @elastic/es-search-aggs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimczi from what you state in the issue description this change makes sense to me. Left one question regarding testing, otherwise LGTM.
@@ -178,8 +180,19 @@ public void collect(int doc, long bucket) throws IOException { | |||
}; | |||
} | |||
|
|||
static Query extractQuery(Query query) { | |||
if (query instanceof BoostQuery) { | |||
return extractQuery(((BoostQuery) query).getQuery()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe its possible to cover this execution branch in the tests as well.
The `composite` aggregation can optimize its execution when the query is a `match_all` or a `range` over the field that is used in the first source of the aggregation. However we only check for instances of `PointRangeQuery` whereas the range query builder creates an `IndexOrDocValuesQuery`. This means that today the optimization does not apply to `range` query even if the code could handle it. This change fixes this issue by extracting the index query inside `IndexOrDocValuesQuery`.
The `composite` aggregation can optimize its execution when the query is a `match_all` or a `range` over the field that is used in the first source of the aggregation. However we only check for instances of `PointRangeQuery` whereas the range query builder creates an `IndexOrDocValuesQuery`. This means that today the optimization does not apply to `range` query even if the code could handle it. This change fixes this issue by extracting the index query inside `IndexOrDocValuesQuery`.
The
composite
aggregation can optimize its execution when the queryis a
match_all
or arange
over the field that is used in the first sourceof the aggregation. However we only check for instances of
PointRangeQuery
whereasthe range query builder creates an
IndexOrDocValuesQuery
. This means thattoday the optimization does not apply to
range
query even if the code could handle it.This change fixes this issue by extracting the index query inside
IndexOrDocValuesQuery
.