Hi,
I discovered that a simple sum aggregation is different to that I write a code to scroll all documents and sum the field value. the value formula is always
${sum-aggregation-result} + 1 == ${scroll-sum}
Elasticsearch Version: 6.3.1
index shard num: 1
index replica : 1
index Mapping is like:
After viewing the source, the SumAggregator use (double) sum += (double) value, is it the reason cause the long value field precision problem?
the compensation value in SumAggregator.getLeafCollector().collect() maybe lead to the precision diff 1.0 between 1.7458313843517748E16 and 17458313843517749
Another question is why sum aggregation use double for all field mapping numeric type? if field type is long, we can use long type in sum aggregation, and we will not lose the precision.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.