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
Count api to become a shortcut to the search api #11198
Count api to become a shortcut to the search api #11198
Conversation
@javanna this looks great!, can we add a test that makes sure that |
Sure @kimchy will add a test. This is the first time (I think) that we make an api shortcut to one another in the java api. The way I did it is very specific to the count api, I wonder if we should support this in a more generic fashion e.g. having some kind of adapter mechanism built-in in Also, do we see the count api sticking around in the java api or will we remove it at some point? I am conflicted on this, I can't make up my mind. Last thing, is the breaking aspect around total failures acceptable or is it going to be a problem? |
I think that we can add it if we see it becoming a pattern, I doubt it will though.
Yea, its a tricky one, I think that this change is great without bothering with the question if we should remove it or not, we can decide later.
No, I think the consistency here between search and count is better. |
Nice diff stats :) |
why are we going through the trouble of having a dedicated Java API here? Java folks still need to recompile their code if they wanna use 2.0 so we can just remove it. REST is a different story but has a way lower footprint. |
I initially wanted to remove the java api layer too, till I realized how much we use the count api in our tests, and I found myself making a change that I didn't like too much: moving to search, adding |
btw pushed another commit as requested by @kimchy |
I would like to get this in, what do we do? Do we want to keep bwc on the java api layer or not? |
It's just sugar, but I think that frequency of use and conciseness is a good enough argument for keeping the count API. |
I agree with @clintongormley I will get this in , @jpountz can you have a last look please? |
LGTM |
The count api used to have its own execution path, although it would do the same (up to bugs!) of the search api. This commit makes it a shortcut to the search api with size set to 0. The change is made in a backwards compatible manner, by leaving all of the java api code around too, given that you may not want to get back a whole SearchResponse when asking only for number of hits matching a query, also cause migrating from countResponse.getCount() to searchResponse.getHits().totalHits() doesn't look great from a user perspective. We can always decide to drop more code around the count api if we want to break backwards compatibility on the java api, making it a shortcut on the rest layer only. Closes elastic#9117 Closes elastic#11198
5b17d22
to
6c81a8d
Compare
The count request now acts like search and barfs if all shards fail this behavior changed and some tests like RecoveryWhileUnderLoadTests relied on the lenient behavior of the old count API. This might be a temporary solution to stop current test failures. Relates to #11198
The count api used to have its own execution path, although it would do the same (up to bugs!) as the search api. This commit makes it a shortcut to the search api with
size
set to0
. The change is made in a backwards compatible manner, by leaving all of the java api code around too, given that you may not want to get back a wholeSearchResponse
when asking only for number of hits matching a query, also cause migrating fromcountResponse.getCount()
tosearchResponse.getHits().totalHits()
doesn't look great from a user perspective. We can always decide to drop more code around the count api if we want to break backwards compatibility on the java api, making it a shortcut on the rest layer only.The only breaking behaviour is around total failures, the search api returns an exception, while the count api used to return a normal response with
count
set to0
,successful
set to0
and a list of shard failures. Maybe we can find a way to maintain this behaviour, but I'm not sure it makes sense.If it wasn't for the above breaking aspect we could potentially backport this change to 1.x, for what it's worth. Let's discuss that.
Closes #9117
Closes #9110