I am experimenting with float/double fields in Elasticsearch (version 6.6.0). I have created this index:
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"amount": {
"type" : "float"
}
}
}
}
}
and I added this entry:
PUT my_index/_doc/1
{
"amount" : 1.0000000000111111111122222222223333333333
}
When I retrieve this document, I get the exact amount I have sent to Elastic:
GET my_index/_doc/1
...
"_source": {
"amount": 1.0000000000111111111122222222223333333333
}
...
By checking the documentation, I would have expected the returning value to have less precision (less digits): Elastic numeric data types documentation
float - A single-precision 32-bit IEEE 754 floating point number, restricted to finite values.
I wonder if Elasticsearch is keeping instead the value as a BigDecimal (or something similar), but I could not find any reference to that.
My question: is this documented somewhere? Am I missing something here?
Following V-K's comment, I have experimented more and I observed that:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With