-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Change HLRC count request to accept a QueryBuilder #46904
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
Change HLRC count request to accept a QueryBuilder #46904
Conversation
Currently the CountRequest accepts a search source builder, while the RestCountAction only accepts a top level query object. This can lead to confusion if another element (e.g. aggregations) is specified, because that will be ignored on the server side in RestCountAction. By deprecating the current setter & constructor that accept a SearchSourceBuilder and adding replacement that accepts a QueryBuilder it is clear what the count api can handle from HLRC side. Follow up from elastic#46829
|
Pinging @elastic/es-core-features |
jimczi
left a comment
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.
I left some minor comments, RequestConverters#count could also use the countRequest directly to serialize the body since CountRequest now implements ToXContentObject ?
| } | ||
|
|
||
| /** | ||
| * @return The provided the query to execute with the count request or |
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.
nit: s/The provided the query/The provided query/
| Objects.equals(routing, that.routing) && | ||
| Objects.equals(preference, that.preference); | ||
| Objects.equals(preference, that.preference) && | ||
| Objects.equals(terminateAfter, that.terminateAfter) && |
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.
good catch :(
| public CountRequest(String[] indices, SearchSourceBuilder searchSourceBuilder) { | ||
| indices(indices); | ||
| this.searchSourceBuilder = searchSourceBuilder; | ||
| this.query = searchSourceBuilder.query(); |
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.
Should we handle a null SearchSourceBuilder ? I guess that it is allowed today.
Yes, I forgot that. I've pushed a new commit that addresses that and the other comments. |
jimczi
left a comment
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.
LGTM
Currently the CountRequest accepts a search source builder, while the RestCountAction only accepts a top level query object. This can lead to confusion if another element (e.g. aggregations) is specified, because that will be ignored on the server side in RestCountAction. By deprecating the current setter & constructor that accept a SearchSourceBuilder and adding replacement that accepts a QueryBuilder it is clear what the count api can handle from HLRC side. Follow up from #46829
Currently the CountRequest accepts a search source builder, while the
RestCountAction only accepts a top level query object. This can lead
to confusion if another element (e.g. aggregations) is specified,
because that will be ignored on the server side in RestCountAction.
By deprecating the current setter & constructor that accept a
SearchSourceBuilder instance and adding replacement that
accepts a QueryBuilder instance it is clear what the count api
can handle from the HLRC side.
Follow up from #46829