elastic / elasticsearch-java

Official Elasticsearch Java Client
Apache License 2.0
6 stars 242 forks source link

Missing required property 'ClusterStatistics.running' #848

Closed mvkazit closed 3 months ago

mvkazit commented 3 months ago

Java API client version

8.14.3

Java version

17

Elasticsearch Version

7.16.2

Problem description

After upgrading ES client to the latest version starts to get following exception:

co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch.core.SearchResponse: co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'ClusterStatistics.running' (JSON path: _clusters) (line no=1, column no=139, offset=-1)

I follow guidelines from: https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/missing-required-property.html

And try to use: https://artifacts.elastic.co/javadoc/co/elastic/clients/elasticsearch-java/8.14.0/co/elastic/clients/util/ApiTypeHelper.html#DANGEROUS_disableRequiredPropertiesCheck(boolean)

Now I am getting: Caused by: co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch.core.SearchResponse: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "co.elastic.clients.util.ApiTypeHelper.requireNonNull(Object, Object, String)" is null (JSON path: _clusters) (line no=1, column no=3348, offset=-1) at

…….

……

Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "co.elastic.clients.util.ApiTypeHelper.requireNonNull(Object, Object, String)" is null

l-trotta commented 3 months ago

Hello! As stated in the Readme:

The Java client is forward compatible; meaning that the client supports communicating with greater or equal minor versions of Elasticsearch without breaking

We don't guarantee compatibility with older versions of the server, especially with older major versions. The disableRequiredPropertiesCheck can help in cases where the difference between versions is only properties becoming required, but if it doesn't work then the only possible solution is to either upgrade the server (recommended) or downgrade the client (not recommended).