-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix NPE with scaled floats stats when field is not indexed #23528
Conversation
This fixes an NPE in finding scaled float stats. The type of min/max methods on the wrapped long stats returns a boxed type, but in the case this is null, the unbox done for the FieldStats.Double ctor primitive types will cause the NPE. These methods would have null for min/max when the field exists, but does not actually have points values. fixes elastic#23487
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.
I left a question.
@@ -268,8 +268,9 @@ public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower | |||
return new FieldStats.Double(stats.getMaxDoc(), stats.getDocCount(), | |||
stats.getSumDocFreq(), stats.getSumTotalTermFreq(), | |||
stats.isSearchable(), stats.isAggregatable(), | |||
stats.getMinValue() == null ? null : stats.getMinValue() / scalingFactor, | |||
stats.getMaxValue() == null ? null : stats.getMaxValue() / scalingFactor); | |||
stats.getMinValue() == null ? 0.0 : stats.getMinValue() / scalingFactor, |
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.
Maybe Double.NaN
?
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.
with regular numerics, we seem to be setting min/max to null in that case. Maybe we should look at the docFreq stat of the fieldstats and call the constructor that does not take min/max values when it is 0?
@jasontedor @jpountz I pushed a change to use the appropriate ctor based on whether the wrapped stats have min/max. |
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.
LGTM
…23528) This fixes an NPE in finding scaled float stats. The type of min/max methods on the wrapped long stats returns a boxed type, but in the case this is null, the unbox done for the FieldStats.Double ctor primitive types will cause the NPE. These methods would have null for min/max when the field exists, but does not actually have points values. fixes #23487
…23528) This fixes an NPE in finding scaled float stats. The type of min/max methods on the wrapped long stats returns a boxed type, but in the case this is null, the unbox done for the FieldStats.Double ctor primitive types will cause the NPE. These methods would have null for min/max when the field exists, but does not actually have points values. fixes #23487
* master: Clear the interrupt flag before joining Migrate to max line length of 100 Docs: Corrected path to elasticsearch-plugin (elastic#23622) Docs: Add comma to reverse nested agg snippet Fix third-party audit task for Gradle 3.4 (elastic#23612) Adapter action future should restore interrupts Update scripting.asciidoc Unmark reindex as experimental CompletionSuggestionContext#toQuery() should also consider text if prefix/regex missing (elastic#23451) Docs: Specify that byte units use powers of 1024 (elastic#23574) Remove Settings.settingsBuilder (elastic#23575) Change params._source to params['_source'] in example. Fix example in documentation for Painless using _source. (elastic#21322) Remove extra line from license header Fix num docs to be positive in bucket deferring collector test Mapping: Fix NPE with scaled floats stats when field is not indexed (elastic#23528)
* single-node-discovery: Clear the interrupt flag before joining Migrate to max line length of 100 Docs: Corrected path to elasticsearch-plugin (elastic#23622) Docs: Add comma to reverse nested agg snippet Fix third-party audit task for Gradle 3.4 (elastic#23612) Adapter action future should restore interrupts Update scripting.asciidoc Unmark reindex as experimental CompletionSuggestionContext#toQuery() should also consider text if prefix/regex missing (elastic#23451) Docs: Specify that byte units use powers of 1024 (elastic#23574) Remove Settings.settingsBuilder (elastic#23575) Change params._source to params['_source'] in example. Fix example in documentation for Painless using _source. (elastic#21322) Remove extra line from license header Fix num docs to be positive in bucket deferring collector test Mapping: Fix NPE with scaled floats stats when field is not indexed (elastic#23528)
This fixes an NPE in finding scaled float stats. The type of min/max
methods on the wrapped long stats returns a boxed type, but in the case
this is null, the unbox done for the FieldStats.Double ctor primitive
types will cause the NPE. These methods would have null for min/max when
the field exists, but does not actually have points values.
fixes #23487