I am using elasticsearch-java api client (8.10.3) and facing a small issue and I hope someone has already encountered this issue before.
I am trying to perform a min aggregation on documents that may not contain the field I try to aggregate. In case that all the documents that match my query don't contain the field I try to aggregate, the "value": null is being deserializing to 0 via the JsonpDeserializer.doubleOrNullDeserializer(0) which is defined inside the setupSingleMetricAggregateBaseDeserializer SingleMetricAggregateBase class
In my opinion, this approach may lead to confusion in our product and I am searching a way to avoid this deserialization but I couldn't find so far. It's ok to return null in that case and I would prefer to achieve this.
any ideas? :)
I tried to add also value count aggregation in order to determine if there are values in the field I try to aggregate and it worked but it is a little weird in my opinion.
You can filter documents without a field by the
exist
querySample documents
Query with a filter and an aggregation
Response
Or you can use the missing parameter with a great number
Response is the same
Convert a favorite query to Java code