elasticsearch-java
elasticsearch-java copied to clipboard
Weird methods in ElasticsearchClient
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
- public BulkResponse bulk()
- public MtermvectorsResponse mtermvectors()
- public FieldCapsResponse fieldCaps()
- public ReindexResponse reindex()
- public RenderSearchTemplateResponse renderSearchTemplate()
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 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!