I noticed rounding issue when using scripting feature of ElasticSearch. I've the following mapping:
{
"my-index": {
"mappings": {
"my-document": {
"properties": {
"id": {
"type": "long"
},
"foo": {
"type": "float"
}
}
}
}
}
}
and a bunch of documents indexed. One document has a value of 159944154.8644
for foo
field. When I send the following query:
{
"query": {
"bool": {
"must": [
{ "match": { "id": 42 } }
]
}
},
"_source": {
"includes": ["id","foo"]
},
"script_fields": {
"foo_scripted": {
"script": {
"lang": "painless",
"inline": "doc['foo'].value"
}
}
}
}
I'm getting the following rounded value in response:
{
"_index": "my-index",
"_type": "my-document",
"_id": "42",
"_score": 1,
"_source": {
"foo": 1.599441548644E8, //= 159944154.8644 -> correct!
"id": 42
},
"fields": {
"foo_scripted": [
1.5994416E8 //= 159944160.0 -> rounded :(
]
}
}
Any idea how to to fix this? Thanks in advance.
ES version: 5.3.0