|
47 | 47 | import org.opensearch.core.xcontent.XContentParser;
|
48 | 48 | import org.opensearch.index.IndexSettings;
|
49 | 49 | import org.opensearch.index.mapper.MapperService;
|
| 50 | +import org.opensearch.index.query.ConstantScoreQueryBuilder; |
50 | 51 | import org.opensearch.index.query.QueryBuilders;
|
51 | 52 | import org.opensearch.index.query.TermQueryBuilder;
|
52 | 53 | import org.opensearch.search.rescore.QueryRescorerBuilder;
|
53 | 54 | import org.opensearch.search.sort.SortOrder;
|
54 | 55 | import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
|
55 | 56 |
|
| 57 | +import java.io.IOException; |
56 | 58 | import java.util.ArrayList;
|
57 | 59 | import java.util.Arrays;
|
58 | 60 | import java.util.Collection;
|
@@ -676,6 +678,23 @@ public void testTermQueryBigInt() throws Exception {
|
676 | 678 | assertEquals(1, searchResponse.getHits().getTotalHits().value);
|
677 | 679 | }
|
678 | 680 |
|
| 681 | + public void testIndexOnlyFloatField() throws IOException { |
| 682 | + prepareCreate("idx").setMapping("field", "type=float,doc_values=false").get(); |
| 683 | + ensureGreen("idx"); |
| 684 | + |
| 685 | + IndexRequestBuilder indexRequestBuilder = client().prepareIndex("idx"); |
| 686 | + |
| 687 | + for (float i = 9000.0F; i < 20000.0F; i++) { |
| 688 | + indexRequestBuilder.setId(String.valueOf(i)).setSource("{\"field\":" + i + "}", MediaTypeRegistry.JSON).get(); |
| 689 | + } |
| 690 | + String queryJson = "{ \"filter\" : { \"terms\" : { \"field\" : [ 10000.0 ] } } }"; |
| 691 | + XContentParser parser = createParser(JsonXContent.jsonXContent, queryJson); |
| 692 | + parser.nextToken(); |
| 693 | + ConstantScoreQueryBuilder query = ConstantScoreQueryBuilder.fromXContent(parser); |
| 694 | + SearchResponse searchResponse = client().prepareSearch("idx").setQuery(query).get(); |
| 695 | + assertEquals(1, searchResponse.getHits().getTotalHits().value); |
| 696 | + } |
| 697 | + |
679 | 698 | public void testTooLongRegexInRegexpQuery() throws Exception {
|
680 | 699 | createIndex("idx");
|
681 | 700 | indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON));
|
|
0 commit comments