Aggregation on double field

Hi all,
I've installed ES on a cluster, first I added a mapping, then put the data on the index.
On a double type field I query for an aggregation.

GET myindex/mytype/_search
{
"query": {
"filtered": {
"query": {
"match": {
"myField": 10
}
},
"filter": {
"range": {
"myDateField": {
"gt": "2015-01-01"
}
}
}
}
},
"aggs": {
"sumOfAMeasureField": {
"sum": {
"field": "myMoneyField"
}
}
}
}

Each run shows different results, like below. there are no failing shards, the number of rows returned is same, but the agg differs

3408065.5425
3408064.765

Any comment?
Regards and thanks

Özgür

This is likely due to floatig point rounding errors: floating point numbers can only approximately represent most values. This means that doing sum = a; sum += b; sum +=c can return a different result from doing sum = c; sum += b; sum +=a since the approximation errors accumulate differently. There is nothing to worry about, this is just the way that floating point numbers work.

1 Like