This repository was archived by the owner on Apr 23, 2026. It is now read-only.
forked from Signal65/elasticsearch-Copilot
-
Notifications
You must be signed in to change notification settings - Fork 1
Scale doubles to floats when necessary to match the field (#78344) #8
Open
MitchLewis930
wants to merge
1
commit into
pr_018_before
Choose a base branch
from
pr_018_after
base: pr_018_before
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import java.io.IOException; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.function.DoubleUnaryOperator; | ||
|
|
||
| public class RangeAggregationBuilder extends AbstractRangeBuilder<RangeAggregationBuilder, Range> { | ||
| public static final String NAME = "range"; | ||
|
|
@@ -152,12 +153,18 @@ protected RangeAggregatorFactory innerBuild( | |
| ) throws IOException { | ||
| RangeAggregatorSupplier aggregatorSupplier = context.getValuesSourceRegistry().getAggregator(REGISTRY_KEY, config); | ||
|
|
||
| /* | ||
| This will downgrade the precision of the range bounds to match the field's precision. Fixes float/double issues, but not | ||
| long/double issues. See https://github.com/elastic/elasticsearch/issues/77033 | ||
| */ | ||
| DoubleUnaryOperator fixPrecision = config.reduceToStoredPrecisionFunction(); | ||
|
|
||
| // We need to call processRanges here so they are parsed before we make the decision of whether to cache the request | ||
| Range[] ranges = processRanges(range -> { | ||
| DocValueFormat parser = config.format(); | ||
| assert parser != null; | ||
| Double from = range.from; | ||
| Double to = range.to; | ||
| Double from = fixPrecision.applyAsDouble(range.from); | ||
| Double to = fixPrecision.applyAsDouble(range.to); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Precision fix not applied to string-specified range valuesMedium Severity When range boundaries are specified as strings (e.g., |
||
| if (range.fromAsStr != null) { | ||
| from = parser.parseDouble(range.fromAsStr, false, context::nowInMillis); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decimal range boundaries throw exceptions on integer fields
High Severity
The
reduceToStoredPrecisionmethod callstype.parse(value, false)withcoerce=falsefor all numeric types. ForINTEGER,LONG,SHORT, andBYTEfields, the parse method throwsIllegalArgumentExceptionwhen the value has a decimal part. This breaks valid use cases where range aggregations use decimal boundaries like{from: 0.5, to: 10.5}on integer fields, which worked before this change.Additional Locations (1)
server/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceConfig.java#L329-L334