PUT my-index
{
"mappings": {
"properties": {
"sf": {
"type": "scaled_float",
"scaling_factor": 10
}
}
}
}
PUT my-index/_doc/1?refresh
{
"sf": 0.3
}
POST /_query?format=txt
{
"query": "FROM my-index"
}
// results in
sf
-------------------
0.30000000000000004
DELETE my-index
PUT my-index
{
"mappings": {
"properties": {
"sf": {
"type": "scaled_float",
"doc_values": false,
"scaling_factor": 10
}
}
}
}
PUT my-index/_doc/1?refresh
{
"sf": 0.3
}
POST /_query?format=txt
{
"query": "FROM my-index"
}
// results in
sf
---------------
0.3
In ESQL different results are returned when using
scaled_floatfield depending if the field has doc values enabled.Steps to reproduce:
This is because of the difference in transforming a rounded long value to a double
https://github.com/elastic/elasticsearch/blob/main/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java#L315
https://github.com/elastic/elasticsearch/blob/main/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java#L389