|
8 | 8 |
|
9 | 9 | import org.apache.lucene.search.FieldExistsQuery; |
10 | 10 | import org.apache.lucene.search.Query; |
| 11 | +import org.elasticsearch.cluster.metadata.IndexMetadata; |
11 | 12 | import org.elasticsearch.common.Strings; |
12 | 13 | import org.elasticsearch.core.CheckedConsumer; |
| 14 | +import org.elasticsearch.index.IndexMode; |
| 15 | +import org.elasticsearch.index.IndexSettings; |
| 16 | +import org.elasticsearch.index.IndexVersions; |
13 | 17 | import org.elasticsearch.index.mapper.DocumentMapper; |
14 | 18 | import org.elasticsearch.index.mapper.DocumentParsingException; |
| 19 | +import org.elasticsearch.index.mapper.IndexType; |
15 | 20 | import org.elasticsearch.index.mapper.LuceneDocument; |
16 | 21 | import org.elasticsearch.index.mapper.MappedFieldType; |
17 | 22 | import org.elasticsearch.index.mapper.Mapper; |
|
20 | 25 | import org.elasticsearch.index.mapper.MapperTestCase; |
21 | 26 | import org.elasticsearch.index.mapper.ParsedDocument; |
22 | 27 | import org.elasticsearch.plugins.Plugin; |
| 28 | +import org.elasticsearch.test.index.IndexVersionUtils; |
23 | 29 | import org.elasticsearch.xcontent.XContentBuilder; |
24 | 30 | import org.elasticsearch.xcontent.XContentFactory; |
25 | 31 | import org.elasticsearch.xcontent.json.JsonXContent; |
@@ -626,6 +632,42 @@ protected List<SortShortcutSupport> getSortShortcutSupport() { |
626 | 632 |
|
627 | 633 | @Override |
628 | 634 | protected boolean supportsDocValuesSkippers() { |
629 | | - return false; |
| 635 | + return false; // can't configure `index` so normal test doesn't work |
| 636 | + } |
| 637 | + |
| 638 | + public void testIndexTypes() throws Exception { |
| 639 | + { |
| 640 | + var indexSettings = getIndexSettingsBuilder().put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES.getName()) |
| 641 | + .put(IndexMetadata.INDEX_ROUTING_PATH.getKey(), "dimension_field") |
| 642 | + .build(); |
| 643 | + MapperService mapperService = createMapperService(indexSettings, fieldMapping(this::minimalMapping)); |
| 644 | + MappedFieldType ft = mapperService.fieldType("field"); |
| 645 | + assertIndexType(ft, IndexType.skippers()); |
| 646 | + } |
| 647 | + { |
| 648 | + var oldVersion = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.STANDARD_INDEXES_USE_SKIPPERS); |
| 649 | + MapperService mapperService = createMapperService(oldVersion, fieldMapping(this::minimalMapping)); |
| 650 | + MappedFieldType ft = mapperService.fieldType("field"); |
| 651 | + assertIndexType(ft, IndexType.points(true, true)); |
| 652 | + } |
| 653 | + { |
| 654 | + MapperService mapperService = createMapperService( |
| 655 | + IndexVersions.STANDARD_INDEXES_USE_SKIPPERS, |
| 656 | + fieldMapping(this::minimalMapping) |
| 657 | + ); |
| 658 | + MappedFieldType ft = mapperService.fieldType("field"); |
| 659 | + assertIndexType(ft, IndexType.skippers()); |
| 660 | + } |
630 | 661 | } |
| 662 | + |
| 663 | + private void assertIndexType(MappedFieldType ft, IndexType indexType) { |
| 664 | + assertThat(ft, instanceOf(AggregateMetricDoubleFieldMapper.AggregateMetricDoubleFieldType.class)); |
| 665 | + AggregateMetricDoubleFieldMapper.AggregateMetricDoubleFieldType aft = |
| 666 | + (AggregateMetricDoubleFieldMapper.AggregateMetricDoubleFieldType) ft; |
| 667 | + assertThat(aft.indexType(), equalTo(indexType)); |
| 668 | + for (MappedFieldType subField : aft.getMetricFields().values()) { |
| 669 | + assertThat(subField.indexType(), equalTo(indexType)); |
| 670 | + } |
| 671 | + } |
| 672 | + |
631 | 673 | } |
0 commit comments