if i have float field in elastic and give value 9999999.9999999 it rounds it to 10000000 how can i put decimal value without rounding ?
I wonder if scaled float could help.
But anyway I'd read this page. https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html
DELETE /test3
PUT /test3
{
"mappings": {
"wildcardtest3": {
"properties": {
"num": {
"type": "scaled_float",
"scaling_factor": 1000000
}
}
}
}
}
PUT test3/test3/2
{
"num": 999999999999.999999
}`
I tried this way by documentation expected result must be all 9s but it rounds number to 1000000000000
If you are testing that in Kibana dev console that might be a Kibana "bug" (or behavior).
If you try to format:
PUT test/_doc/1
{
"num": 999999999999.999999
}
You will see that Kibana transforms that number to:
PUT test/_doc/1
{
"num": 1000000000000
}
I suspect that Kibana (or the browser) does that transformation before sending to elasticsearch.
Here is a workaround I found. Note that I'm using also here double
instead of float
.
DELETE /test
PUT /test
{
"mappings": {
"_doc": {
"properties": {
"num": {
"type": "double"
}
}
}
}
}
PUT test/_doc/1
{
"num": "999999999999.999999"
}
GET test/_doc/1
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.