IncludeExclude does not need formatter when converting longs #38739
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using the formatter converts longs (wrapped in a
BytesRef
) to a double, then rounds/truncates back to a long. This loses precision for large longs.I might be missing something, but I think we should instead just convert the string value directly to a long.
The disadvantage is that a floating point value will throw a
NumberFormatException
, but it looks like this shouldn't be a problem. The only two usages are by terms and sigterms aggs, and both check if the number is a float first and useconvertToDoubleFilter()
.We could fall back to the old behavior if a
NumberFormatException
is thrown, but this feels wrong to me since we should only be dealing with longs in the long filter, and silently truncating precision is worse than just throwing an exception imo.Closes #38692