45
45
import org .elasticsearch .index .fielddata .plain .SortedNumericIndexFieldData ;
46
46
import org .elasticsearch .index .mapper .TimeSeriesParams .MetricType ;
47
47
import org .elasticsearch .index .query .SearchExecutionContext ;
48
- import org .elasticsearch .lucene .document .NumericField ;
49
48
import org .elasticsearch .lucene .search .XIndexSortSortedNumericDocValuesRangeQuery ;
50
49
import org .elasticsearch .script .DoubleFieldScript ;
51
50
import org .elasticsearch .script .LongFieldScript ;
@@ -353,19 +352,13 @@ public Float parse(XContentParser parser, boolean coerce) throws IOException {
353
352
}
354
353
355
354
@ Override
356
- public Query termQuery (String field , Object value , boolean isIndexed , boolean hasDocValues ) {
355
+ public Query termQuery (String field , Object value , boolean isIndexed ) {
357
356
float v = parseToFloat (value );
358
357
if (Float .isFinite (HalfFloatPoint .sortableShortToHalfFloat (HalfFloatPoint .halfFloatToSortableShort (v ))) == false ) {
359
358
return Queries .newMatchNoDocsQuery ("Value [" + value + "] is out of range" );
360
359
}
361
360
362
361
if (isIndexed ) {
363
- if (hasDocValues ) {
364
- return new IndexOrDocValuesQuery (
365
- HalfFloatPoint .newExactQuery (field , v ),
366
- SortedNumericDocValuesField .newSlowExactQuery (field , HalfFloatPoint .halfFloatToSortableShort (v ))
367
- );
368
- }
369
362
return HalfFloatPoint .newExactQuery (field , v );
370
363
} else {
371
364
return SortedNumericDocValuesField .newSlowExactQuery (field , HalfFloatPoint .halfFloatToSortableShort (v ));
@@ -549,15 +542,13 @@ public Float parse(XContentParser parser, boolean coerce) throws IOException {
549
542
}
550
543
551
544
@ Override
552
- public Query termQuery (String field , Object value , boolean isIndexed , boolean hasDocValues ) {
545
+ public Query termQuery (String field , Object value , boolean isIndexed ) {
553
546
float v = parseToFloat (value );
554
547
if (Float .isFinite (v ) == false ) {
555
548
return new MatchNoDocsQuery ("Value [" + value + "] is out of range" );
556
549
}
557
550
558
- if (isIndexed && hasDocValues ) {
559
- return FloatField .newExactQuery (field , v );
560
- } else if (isIndexed ) {
551
+ if (isIndexed ) {
561
552
return FloatPoint .newExactQuery (field , v );
562
553
} else {
563
554
return SortedNumericDocValuesField .newSlowExactQuery (field , NumericUtils .floatToSortableInt (v ));
@@ -724,15 +715,13 @@ public FieldValues<Number> compile(String fieldName, Script script, ScriptCompil
724
715
}
725
716
726
717
@ Override
727
- public Query termQuery (String field , Object value , boolean isIndexed , boolean hasDocValues ) {
718
+ public Query termQuery (String field , Object value , boolean isIndexed ) {
728
719
double v = objectToDouble (value );
729
720
if (Double .isFinite (v ) == false ) {
730
721
return Queries .newMatchNoDocsQuery ("Value [" + value + "] has a decimal part" );
731
722
}
732
723
733
- if (isIndexed && hasDocValues ) {
734
- return DoubleField .newExactQuery (field , v );
735
- } else if (isIndexed ) {
724
+ if (isIndexed ) {
736
725
return DoublePoint .newExactQuery (field , v );
737
726
} else {
738
727
return SortedNumericDocValuesField .newSlowExactQuery (field , NumericUtils .doubleToSortableLong (v ));
@@ -886,12 +875,12 @@ public Byte parse(XContentParser parser, boolean coerce) throws IOException {
886
875
}
887
876
888
877
@ Override
889
- public Query termQuery (String field , Object value , boolean isIndexed , boolean hasDocValues ) {
878
+ public Query termQuery (String field , Object value , boolean isIndexed ) {
890
879
if (isOutOfRange (value )) {
891
880
return new MatchNoDocsQuery ("Value [" + value + "] is out of range" );
892
881
}
893
882
894
- return INTEGER .termQuery (field , value , isIndexed , hasDocValues );
883
+ return INTEGER .termQuery (field , value , isIndexed );
895
884
}
896
885
897
886
@ Override
@@ -1010,11 +999,11 @@ public Short parse(XContentParser parser, boolean coerce) throws IOException {
1010
999
}
1011
1000
1012
1001
@ Override
1013
- public Query termQuery (String field , Object value , boolean isIndexed , boolean hasDocValues ) {
1002
+ public Query termQuery (String field , Object value , boolean isIndexed ) {
1014
1003
if (isOutOfRange (value )) {
1015
1004
return Queries .newMatchNoDocsQuery ("Value [" + value + "] is out of range" );
1016
1005
}
1017
- return INTEGER .termQuery (field , value , isIndexed , hasDocValues );
1006
+ return INTEGER .termQuery (field , value , isIndexed );
1018
1007
}
1019
1008
1020
1009
@ Override
@@ -1136,7 +1125,7 @@ public Integer parse(XContentParser parser, boolean coerce) throws IOException {
1136
1125
}
1137
1126
1138
1127
@ Override
1139
- public Query termQuery (String field , Object value , boolean isIndexed , boolean hasDocValues ) {
1128
+ public Query termQuery (String field , Object value , boolean isIndexed ) {
1140
1129
if (hasDecimalPart (value )) {
1141
1130
return Queries .newMatchNoDocsQuery ("Value [" + value + "] has a decimal part" );
1142
1131
}
@@ -1147,9 +1136,7 @@ public Query termQuery(String field, Object value, boolean isIndexed, boolean ha
1147
1136
}
1148
1137
int v = parse (value , true );
1149
1138
1150
- if (isIndexed && hasDocValues ) {
1151
- return NumericField .newExactIntQuery (field , v );
1152
- } else if (isIndexed ) {
1139
+ if (isIndexed ) {
1153
1140
return IntPoint .newExactQuery (field , v );
1154
1141
} else {
1155
1142
return SortedNumericDocValuesField .newSlowExactQuery (field , v );
@@ -1322,7 +1309,7 @@ public FieldValues<Number> compile(String fieldName, Script script, ScriptCompil
1322
1309
}
1323
1310
1324
1311
@ Override
1325
- public Query termQuery (String field , Object value , boolean isIndexed , boolean hasDocValues ) {
1312
+ public Query termQuery (String field , Object value , boolean isIndexed ) {
1326
1313
if (hasDecimalPart (value )) {
1327
1314
return Queries .newMatchNoDocsQuery ("Value [" + value + "] has a decimal part" );
1328
1315
}
@@ -1331,9 +1318,7 @@ public Query termQuery(String field, Object value, boolean isIndexed, boolean ha
1331
1318
}
1332
1319
1333
1320
long v = parse (value , true );
1334
- if (isIndexed && hasDocValues ) {
1335
- return NumericField .newExactLongQuery (field , v );
1336
- } else if (isIndexed ) {
1321
+ if (isIndexed ) {
1337
1322
return LongPoint .newExactQuery (field , v );
1338
1323
} else {
1339
1324
return SortedNumericDocValuesField .newSlowExactQuery (field , v );
@@ -1517,7 +1502,7 @@ public final TypeParser parser() {
1517
1502
return parser ;
1518
1503
}
1519
1504
1520
- public abstract Query termQuery (String field , Object value , boolean isIndexed , boolean hasDocValues );
1505
+ public abstract Query termQuery (String field , Object value , boolean isIndexed );
1521
1506
1522
1507
public abstract Query termsQuery (String field , Collection <?> values );
1523
1508
@@ -1908,11 +1893,11 @@ public NumberFieldType(
1908
1893
}
1909
1894
1910
1895
public NumberFieldType (String name , NumberType type ) {
1911
- this (name , type , true , true );
1896
+ this (name , type , true );
1912
1897
}
1913
1898
1914
- public NumberFieldType (String name , NumberType type , boolean isIndexed , boolean hasDocValues ) {
1915
- this (name , type , isIndexed , false , hasDocValues , true , null , Collections .emptyMap (), null , false , null , null , false );
1899
+ public NumberFieldType (String name , NumberType type , boolean isIndexed ) {
1900
+ this (name , type , isIndexed , false , true , true , null , Collections .emptyMap (), null , false , null , null , false );
1916
1901
}
1917
1902
1918
1903
@ Override
@@ -1951,7 +1936,7 @@ public boolean isSearchable() {
1951
1936
@ Override
1952
1937
public Query termQuery (Object value , SearchExecutionContext context ) {
1953
1938
failIfNotIndexedNorDocValuesFallback (context );
1954
- return type .termQuery (name (), value , isIndexed (), hasDocValues () );
1939
+ return type .termQuery (name (), value , isIndexed ());
1955
1940
}
1956
1941
1957
1942
@ Override
0 commit comments