scale_float does not honor limits for long values #105361
Labels
>bug
:Search/Mapping
Index mappings, including merging and defining field types
Team:Search
Meta label for search team
Elasticsearch Version
7.17 / 8.x
Installed Plugins
No response
Java Version
bundled
OS Version
N/A
Problem Description
When using
scaled_float
, there is no range check on the value and scaling factor to be outside thelong
value range.According to documentation for
scaled_float
:However, that assumption is not checked on document ingestion. The following mapping:
"properties": {
"a_scaled_float": {
"scaling_factor": 1000000,
"type": "scaled_float"
}
There's a scaled_float mapping configuration with value 1000000.
So, why did the number 1707339753294418 become 9223372036854.775? Shouldn't it be 1707339753294418000000?
{
"_index": "test-index",
"_id": "Z5t_iY0BLRoRMvLbP6e3",
"_score": 1,
"_source": {
"a_scaled_float": 1707339753294418
},
"fields": {
"a_scaled_float": [
9223372036854.775
]
}
}
This is due to the rounding up done here, which produces a
long
value which is outside range, and thus returnsMAX_LONG
.As this provides an incorrect result, and the value is outside of the
long
range, the correct behaviour should be to error on the value as other numeric types do.Steps to Reproduce
Set a mapping with properties:
Ingest a document:
This should return an error, as the number is outside the
long
range.Logs (if relevant)
No response
The text was updated successfully, but these errors were encountered: