@@ -276,4 +276,23 @@ public void testParseIp() {
276276 assertEquals (InetAddresses .forString ("::1" ), RangeFieldMapper .RangeType .IP .parse ("::1" , randomBoolean ()));
277277 assertEquals (InetAddresses .forString ("::1" ), RangeFieldMapper .RangeType .IP .parse (new BytesRef ("::1" ), randomBoolean ()));
278278 }
279+
280+ public void testTermQuery () throws Exception , IllegalArgumentException {
281+ // See https://github.com/elastic/elasticsearch/issues/25950
282+ Settings indexSettings = Settings .builder ()
283+ .put (IndexMetaData .SETTING_VERSION_CREATED , Version .CURRENT ).build ();
284+ IndexSettings idxSettings = IndexSettingsModule .newIndexSettings (randomAlphaOfLengthBetween (1 , 10 ), indexSettings );
285+ QueryShardContext context = new QueryShardContext (0 , idxSettings , null , null , null , null , null , xContentRegistry (),
286+ writableRegistry (), null , null , () -> nowInMillis , null );
287+ RangeFieldMapper .RangeFieldType ft = new RangeFieldMapper .RangeFieldType (type , Version .CURRENT );
288+ ft .setName (FIELDNAME );
289+ ft .setIndexOptions (IndexOptions .DOCS );
290+
291+ Object value = nextFrom ();
292+ ShapeRelation relation = ShapeRelation .INTERSECTS ;
293+ boolean includeLower = true ;
294+ boolean includeUpper = true ;
295+ assertEquals (getExpectedRangeQuery (relation , value , value , includeLower , includeUpper ),
296+ ft .termQuery (value , context ));
297+ }
279298}
0 commit comments