Skip to content

Conversation

@martijnvg
Copy link
Member

@martijnvg martijnvg commented Sep 20, 2019

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

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
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

@martijnvg martijnvg changed the title Change HLRC count request should accept a QueryBuilder Change HLRC count request to accept a QueryBuilder Sep 20, 2019
Copy link
Contributor

@jimczi jimczi left a 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
Copy link
Contributor

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) &&
Copy link
Contributor

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();
Copy link
Contributor

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.

@martijnvg
Copy link
Member Author

RequestConverters#count could also use the countRequest directly to serialize the body since CountRequest now implements ToXContentObject

Yes, I forgot that. I've pushed a new commit that addresses that and the other comments.

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@martijnvg martijnvg merged commit 81fce5c into elastic:master Sep 23, 2019
martijnvg added a commit that referenced this pull request Sep 23, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants