It seems double field under a float property loses precision in ES8. What changed on ES8? Is there a way to configure it (mapping/index/cluster) so it doesn't lose precision?
I tested with the following index
PUT test.double
{
"mappings": {
"properties": {
"amount" : {
"type" : "float",
"fields": {
"d": {
"type": "double"
}
}
}
}
}
}
post some sample data
POST test.double/_bulk
{ "index" : { "_id" : "1" } }
{ "amount" : 856250000 }
{ "index" : { "_id" : "2" } }
{ "amount" : 856250000 }
{ "index" : { "_id" : "3" } }
{ "amount" : 856250000 }
{ "index" : { "_id" : "4" } }
{ "amount" : 856250000 }
run the following aggregation
GET test.double/_search
{
"size": 0,
"aggs": {
"float": {
"sum": { "field": "amount"}
},
"float.d": {
"sum": { "field": "amount.d"}
}
}
}
it produces different result on ES7 vs ES8.
in ES7 (correct)
"aggregations" : {
"float.d" : {
"value" : 3.425E9
},
"float" : {
"value" : 3.424999936E9
}
}
in ES8 (incorrect)
"aggregations" : {
"float.d" : {
"value" : 3.424999936E9
},
"float" : {
"value" : 3.424999936E9
}
}
I've tested with several other combination on ES8
- property is
keyword
, field isfloat
anddouble
> correct result - property is
integer
, field isfloat
anddouble
>double
is correct butfloat
field returns integer value (test data has decimal point)
it seems float
type has some issues