-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Add support for indices exists to REST high level client #27384
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
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
@karmi Done! |
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.
Async version needed?
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 can remove this, if needed.
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.
yes please, I commented above about it, before seeing your question ;)
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 will revert.
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.
Most probably this is not needed, I'll remove.
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 believe none of this is really needed...
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.
It might have been better to move this method into IndicesExistsResponse
, but Response
is not visible from IndicesExistsResponse
.
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.
use the already existing convertExistsResponse from RestHighLevelClient, you can see how this is done in the ping method for instance.
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 @hariso , this looks pretty good, I will remove the WIP label. If you can add docs and address the few comments I left, I will merge this. Thanks!
On your questions: naming is good as-is. We do need the async version I think, which you have already added, so nothing to do there. The behaviour of the API when multiple indices are passed in can be controlled through indices options which are currently not supported in your PR, you'll see a comment about that. Once you support those you just have to return true if 200 and false if 404.
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.
use the already existing convertExistsResponse from RestHighLevelClient, you can see how this is done in the ping method for instance.
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: can you revert the addition of the static import? It affects also other methods that you are not changing and that causes some noise in the 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.
Will do 👍
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: can you revert the addition of the static import? It affects also other methods that you are not changing and that causes some noise in the 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.
Will do 👍
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.
yes please, I commented above about it, before seeing your question ;)
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.
can you remove this empty line please?
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.
Will do 👍
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 would prefer not using underscore as part of method names if possible. can you remove this one and the following ones please?
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!
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 that one test here is enough. test it with a random number of indices ?
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! Test is now using up to 10 indices with random names.
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.
we should add support here for some missing parameters, see https://github.com/elastic/elasticsearch/blob/master/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists.json .
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.
@javanna I implemented this. Two values I could extract from IndicesExistsRequest I did. Please double check, since I have the feeling I missed something.
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.
can you make this final?
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 guess you mean the method and not parameters ("this" and not "these"), but I'd like to double check.: )
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.
yes the method.
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.
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.
can you make this final?
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.
hi @hariso do you think you'll have time to get back to this PR, merge master in and make the requested changes above? Thanks! |
@javanna Thanks a lot for the feedback! I did a few small refactorings in the tests. I'll now address the other comments and let you once all of that is done. |
|
||
private static void setRandomIncludeDefaults(GetIndexRequest request, Map<String, String> expectedParams) { | ||
if (randomBoolean()) { | ||
request.includeDefaults(true); |
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.
can we also randomize the value, just to test what we do when the value is explicitly set to false? It is the default value but I would prefer to test that codepath too. Same for the other new methods.
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!
request.local(true); | ||
expectedParams.put("local", Boolean.TRUE.toString()); | ||
} | ||
} |
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 work!
@javanna Another batch of changes is in!
This is obviously the two new fields, |
|
||
assertEquals(HttpHead.METHOD_NAME, request.getMethod()); | ||
assertEquals("/" + String.join(",", indices), request.getEndpoint()); | ||
assertThat(expectedParams, equalTo(request.getParameters())); |
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: can you assert that request.getEntity is null please?
private Feature[] features = DEFAULT_FEATURES; | ||
private boolean humanReadable = false; | ||
private boolean flatSettings = false; | ||
private boolean includeDefaults = false; |
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 point that you make on these not being serializable is a good one. I think that is a good choice, if we want to make it more explicit we could mark these transient
<2> Return result in a format suitable for humans. | ||
<3> Whether to return all default setting for each of the indices. | ||
<4> Return settings in flat format. | ||
<5> Controls how unavailable indices are resolved and how wildcard expressions are expanded. |
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: can you remove the punctuation mark at the end of these notes?
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-async] | ||
-------------------------------------------------- | ||
<1> Called when the execution is successfully completed. The response is provided as an argument. | ||
<2> Called in case of failure. The raised exception is provided as an argument. |
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 the final punctuation marks?
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.
this is ready @hariso . I left a couple of very minor comments. Docs look good. if you can address the last few comments I will merge this.
@javanna Docs and tests updated. I just realized one thing, and that is that it may be good to combine three different tests for Indices Exists API from |
include::deleteindex.asciidoc[] | ||
======= | ||
include::delete_index.asciidoc[] | ||
>>>>>>> master |
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.
could you fix this? A merge gone wrong I think
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.
include::deleteindex.asciidoc[] should go, it's been replaced by include::delete_index.asciidoc[]
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.
Fixed, thanks for noticing it!
thanks a lot @hariso ! |
Thank you for all the stuff I learnt here! No wonder Elasticsearch is such a great piece of software! |
This is obviously work in progress, but I opened the PR to ask a few questions: