elastic / elasticsearch-java

Official Elasticsearch Java Client
Apache License 2.0
412 stars 239 forks source link

mtermvectors fails when deserializing response if field_statistics is set to false #839

Closed spacelore closed 2 months ago

spacelore commented 3 months ago

Java API client version

8.14.1

Java version

21

Elasticsearch Version

8.14.1

Problem description

There is an option in the api to not retrieve field statistics when executing a mtermvector request but doing so results in an error when deserializing the response. This is related to #838 and #716.

POST /_mtermvectors 
{"docs":[{"_id":"1","_index":"my-index","fields":["transcript:en:content"],"field_statistics":false,"offsets":true,"positions":true}]}
Caused by: co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch.core.mtermvectors.MultiTermVectorsResult: co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'TermVector.fieldStatistics' (JSON path: docs[0].term_vectors['transcript:en:content']) (line no=1, column no=8503, offset=-1)
    at co.elastic.clients.json.JsonpMappingException.from0(JsonpMappingException.java:134) ~[elasticsearch-java-8.14.1.jar:?]
    at co.elastic.clients.json.JsonpMappingException.from(JsonpMappingException.java:121) ~[elasticsearch-java-8.14.1.jar:?]
    at co.elastic.clients.json.JsonpDeserializerBase$StringMapDeserializer.deserialize(JsonpDeserializerBase.java:353) ~[elasticsearch-java-8.14.1.jar:?]
    at co.elastic.clients.json.JsonpDeserializerBase$StringMapDeserializer.deserialize(JsonpDeserializerBase.java:333) ~[elasticsearch-java-8.14.1.jar:?]
l-trotta commented 3 months ago

Hello, thanks for reporting this! Both this and #838 are errors in the API specification which we use to generate the client, we'll fix it there and regenerate the code to solve the issue.