Fix NPE when running a range query on a `scaled_float` with no upper bound. #20253

The null check was there, but on the wrong variable.
This commit is contained in:
Adrien Grand 2016-08-31 15:30:26 +02:00
parent a0becd26b1
commit 34aaea641d
2 changed files with 3 additions and 3 deletions

View File

@ -244,7 +244,7 @@ public class ScaledFloatFieldMapper extends FieldMapper {
lo = Math.round(Math.ceil(dValue * scalingFactor));
}
Long hi = null;
if (lowerTerm != null) {
if (upperTerm != null) {
double dValue = NumberFieldMapper.NumberType.DOUBLE.parse(upperTerm).doubleValue();
if (includeUpper == false) {
dValue = Math.nextDown(dValue);

View File

@ -117,8 +117,8 @@ public class ScaledFloatFieldTypeTests extends FieldTypeTestCase {
IndexSearcher searcher = newSearcher(reader);
final int numQueries = 1000;
for (int i = 0; i < numQueries; ++i) {
double l = (randomDouble() * 2 - 1) * 10000;
double u = (randomDouble() * 2 - 1) * 10000;
Double l = randomBoolean() ? null : (randomDouble() * 2 - 1) * 10000;
Double u = randomBoolean() ? null : (randomDouble() * 2 - 1) * 10000;
boolean includeLower = randomBoolean();
boolean includeUpper = randomBoolean();
Query doubleQ = NumberFieldMapper.NumberType.DOUBLE.rangeQuery("double", l, u, includeLower, includeUpper);