Add support for indices exists to REST high level client#27384
Add support for indices exists to REST high level client#27384javanna merged 31 commits intoelastic:masterfrom hariso:hlrc-indices-exist
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.
Async version needed?
There was a problem hiding this comment.
I can remove this, if needed.
There was a problem hiding this comment.
yes please, I commented above about it, before seeing your question ;)
There was a problem hiding this comment.
Most probably this is not needed, I'll remove.
There was a problem hiding this comment.
I believe none of this is really needed...
There was a problem hiding this comment.
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.
use the already existing convertExistsResponse from RestHighLevelClient, you can see how this is done in the ping method for instance.
javanna
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
yes please, I commented above about it, before seeing your question ;)
There was a problem hiding this comment.
can you remove this empty line please?
There was a problem hiding this comment.
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.
I think that one test here is enough. test it with a random number of indices ?
There was a problem hiding this comment.
Done! Test is now using up to 10 indices with random names.
There was a problem hiding this comment.
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.
@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.
I guess you mean the method and not parameters ("this" and not "these"), but I'd like to double check.: )
|
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.
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.
| request.local(true); | ||
| expectedParams.put("local", Boolean.TRUE.toString()); | ||
| } | ||
| } |
|
@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.
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.
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.
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.
remove the final punctuation marks?
|
@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.
could you fix this? A merge gone wrong I think
There was a problem hiding this comment.
include::deleteindex.asciidoc[] should go, it's been replaced by include::delete_index.asciidoc[]
There was a problem hiding this comment.
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: