-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add CountRequest/Response classes to server and use them in RestCountAction (cat and doc). #32711
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
Add CountRequest/Response classes to server and use them in RestCountAction (cat and doc). #32711
Conversation
…RestCountAction (cat and doc). At the moment there are no CountRequest and CountResponse classes, and RestCountAction will return SearchResponse with XContent generated dynamically (inline), this PR adds CountRequest and CountResponse. During review of elastic#31868 it was decided to separate elastic#31868 into two PRs and this is first part.
|
Pinging @elastic/es-core-infra |
|
Hey @mrdjen ive been on vacation for a week. Im going to look at this in the next day or two, i promise :) I noticed you wrapped the |
|
Hi @hub-cap, good to have you back! Hope you enjoyed your vacation, as I'll have mine soon as well :) Had a quick look to have separate So There's one thing I think needs to change though, Let me know what you think. |
|
Im only ok with this approach assuming there is no way to get to the search request itself. For instance, you have a Looking at SearchRequest, of the 13 private variables in master, it looks like only 6 of those are duplicated, and 2 of those 6 are already built out for you (the non primitive types), so you do not need to do anything WRT their transport read/write code, which is a lot of the effort in the actions here. Im still on the fence, but I will definitely look more at this code tomorrow, and probably try to implement it just to see how duplicated it is. |
|
Right Another problem is the need to expose But maybe I'm missing something, its too late, curious to see how it goes from here :) |
|
Hi @mrdjen, sorry for being M.I.A. again, as I have been trying to figure out the future of the rest client and its dependencies (or lack thereof!). Ill have more info in a day or two, so hold tight. This will probably not affect you, but Ill definitely be giving you an approval or ask you to fix something in the next day or two. |
|
Hi @hub-cap, if you have any comments let me know, |
|
Hi, @mrdjen did you ever submit a PR that did not use a search request as a member variable to the count request? Coming back to this, I think I would like to see what it looks like w/o holding the state of the search request. We are moving away from reusing these classes in the rest client, and implementing ones that do not extend ActionRequest/ActionResponse, so it would be good to split them up and not tie them together. Lets go that route and see what it looks like. You can keep this PR open for now, but I think duplicating the code is fine now. Hopefully one day all of the client code will be generated anyway ;) ;) |
|
Hi @hub-cap no I didn't submit a PR without If we go this way, not using directly |
|
Do you expect that the |
…RestCountAction (cat and doc). Changes requested - instead of wrapping SearchRequest, now CountRequest inlines required members from SearchRequest - SearchSourceBuilder as member - validate to return null elastic#32711
|
Hi @hub-cap I've addressed/made following changes
When it comes to "not messing around with Let me know your comments, hopefully I can resolve whatever is left and if/once this is accepted I'll merge it into original #31868 |
|
Awesome, tyvm! Ill have a look shortly. |
hub-cap
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 think this is totally the right direction. There are a few minor style nits but this is exactly what we should be doing. Lets wait to merge anything in to your other code until we get this merged in to server. I will also find someone who has more familiarity with search to review it.
| public CountResponse(SearchResponse searchResponse) { | ||
| this.count = searchResponse.getHits().totalHits; | ||
| this.terminatedEarly = searchResponse.isTerminatedEarly(); | ||
| this.shardStats = new ShardStats(searchResponse.getSuccessfulShards(), searchResponse.getTotalShards(),searchResponse |
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.
getTotalShards(),searchResponse can you put searchResponse on the next line?
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.
ok
| } | ||
| } | ||
|
|
||
|
|
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.
Remove these empty lines pls
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.
done
| parser.skipChildren(); | ||
| } | ||
| } | ||
| return new ShardStats(successfulShards,totalShards,skippedShards,failures.toArray(new ShardSearchFailure[failures.size()])); |
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.
spaces between commas
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.
done
| } | ||
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { |
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.
the XContent here does not match what you removed in the REST API. There was a bit about early termination, as well as count that you need to include. You likely need to also include the begin/end calls, or else this will fail tests.
You can check the tests with ./gradlew :server:check from the base of the checkout. If tests dont fail then we need some better tests around the response hehe
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.
Hey think you're looking at XContent of ShardStats (which innner class of CountRequest), and ShardStats indeed handles only the _shards part of the response.
count is added up at line 150 of CountRequest, terminated_early at line 152, and then at line 154 CountRequest will make a call to inner class ShardStats.toXContent
I've added the radnomized tests which also include ShardFailures and terminated_early, and ./gradlew clean server:check runs fine
So as much as I'm aware of this part is ok (at least regarding this comment), can you please check again?
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.
Hi, I was referring to this code, https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/rest/action/document/RestCountAction.java#L95-L104 , which you deleted as part of your PR.
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.
Wow, you are totally right, I see that now :)
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.
👍
|
hi @hub-cap |
|
@elasticmachine test this please |
|
@colings86 Ive added you as a reviewer because this is something we have discussed. Feel free to delegate :) |
|
hey @mrdjen I had a chat w/ @colings86 and there is some history here that I was unaware of, that caused him to reach out to me. Historically we had server side count actions, like the ones youve proposed above. They were removed in favor of only a rest API in server. So this means that we will not be putting the request/response in server. That being said, these classes are 100% necessary for the high level rest API. We are no longer reusing the server side APIs so we need to start putting them in the high level client project themselves. So the work you did was not in vain, we just need to move them into client and use them there, and not touch anything in server. Does this make sense? |
|
No problem hub-cap, let me just do a quick recap - Initially, I've submitted 31868, and as javanna suggested, A new PR was requested (this one) by hub-cap, move The last comment suggests using This does not sound like a big work and I'm eager to push this over the line. Can you guys please confirm/clarify if my understanding is correct and do you have any preferences regarding PR's (which to use to complete the remaining work)? @javanna, @hub-cap, @colings86 Note to the casual reader - read the conversation from the start of 31868, submitted back on July 6th. Cheers! Milan |
|
@mrdjen Sorry for the back and forth on this one. I'm +1 on having the |
|
Thanks @colings86 |
|
thanks for your patience @mrdjen , greatly appreciated! A lot of work is going into the high-level REST client these days by the team and we were still defining the overall direction, hence the back and forth ;) |
|
yea, we did totally drop the ball on this and give you a lot of rework. I take blame/responsibility. I am sorry @mrdjen , as it was my fault to tell you to move it in to server, and I did not know the history. Thank you for your persistence. |
|
Hey @hub-cap no problem, I'm glad to contribute and there are many moving parts. |
|
Hi guys, |
|
@mrdjen we can close this right? |
|
Yeah, closing it now @hub-cap |
|
Thanks! |
At the moment there are no
CountRequestandCountResponseclasses, andRestCountActionwill returnSearchResponsewith XContent generated dynamically (inline). This PR addsCountRequestandCountResponse, and changesRestCountActionso it will use the newly added classes.This was initiated during review of #31868, it was decided to separate #31868 into two PRs and this is first part.
relates #31868
@hub-cap