elasticsearch-java icon indicating copy to clipboard operation
elasticsearch-java copied to clipboard

Weird methods in ElasticsearchClient

Open darxriggs opened this issue 2 years ago • 1 comments

There are methods in ElasticsearchClient that look like not very useful.

They do not take any parameter, therefore using the builder internally without setting any value. When called, they raise an IllegalStateException.

Examples

Looking at the API documentation, there is a least some mandatory parameter.

Is this maybe the result of generating the client based on the API specification and they should better be removed?

darxriggs avatar Jan 29 '22 16:01 darxriggs

@darxriggs you're right. The code generator produces a no-parameter version of API methods when all properties of the request object are optional. For some of requests that was an error as some properties are actually required (see specification PRs linked above) but for some others at least one of these properties must be set.

We'll take a different approach and generate these no-parameter methods from an opt-in list where we know that this is indeed correct. In the meantime, well, avoid using these 😉

And thank you for having reported this!

swallez avatar Mar 22 '22 17:03 swallez