|
@@ -276,4 +276,23 @@ public class RangeFieldTypeTests extends FieldTypeTestCase {
|
|
|
assertEquals(InetAddresses.forString("::1"), RangeFieldMapper.RangeType.IP.parse("::1", randomBoolean()));
|
|
|
assertEquals(InetAddresses.forString("::1"), RangeFieldMapper.RangeType.IP.parse(new BytesRef("::1"), randomBoolean()));
|
|
|
}
|
|
|
+
|
|
|
+ public void testTermQuery() throws Exception, IllegalArgumentException {
|
|
|
+ // See https://github.com/elastic/elasticsearch/issues/25950
|
|
|
+ Settings indexSettings = Settings.builder()
|
|
|
+ .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
|
|
|
+ IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings);
|
|
|
+ QueryShardContext context = new QueryShardContext(0, idxSettings, null, null, null, null, null, xContentRegistry(),
|
|
|
+ writableRegistry(), null, null, () -> nowInMillis, null);
|
|
|
+ RangeFieldMapper.RangeFieldType ft = new RangeFieldMapper.RangeFieldType(type, Version.CURRENT);
|
|
|
+ ft.setName(FIELDNAME);
|
|
|
+ ft.setIndexOptions(IndexOptions.DOCS);
|
|
|
+
|
|
|
+ Object value = nextFrom();
|
|
|
+ ShapeRelation relation = ShapeRelation.INTERSECTS;
|
|
|
+ boolean includeLower = true;
|
|
|
+ boolean includeUpper = true;
|
|
|
+ assertEquals(getExpectedRangeQuery(relation, value, value, includeLower, includeUpper),
|
|
|
+ ft.termQuery(value, context));
|
|
|
+ }
|
|
|
}
|