|
91 | 91 | import org.opensearch.index.mapper.DocumentMapper; |
92 | 92 | import org.opensearch.index.mapper.MapperService; |
93 | 93 | import org.opensearch.index.mapper.MapperService.MergeReason; |
94 | | -import org.opensearch.index.mapper.Mapping; |
95 | 94 | import org.opensearch.index.query.QueryShardContext; |
96 | 95 | import org.opensearch.index.remote.RemoteStoreCustomMetadataResolver; |
97 | 96 | import org.opensearch.index.remote.RemoteStoreEnums.PathHashAlgorithm; |
|
101 | 100 | import org.opensearch.index.translog.Translog; |
102 | 101 | import org.opensearch.indices.IndexCreationException; |
103 | 102 | import org.opensearch.indices.IndicesService; |
104 | | -import org.opensearch.indices.InvalidAliasNameException; |
105 | 103 | import org.opensearch.indices.InvalidIndexContextException; |
106 | 104 | import org.opensearch.indices.InvalidIndexNameException; |
107 | | -import org.opensearch.indices.InvalidIndexTemplateException; |
108 | 105 | import org.opensearch.indices.RemoteStoreSettings; |
109 | 106 | import org.opensearch.indices.ShardLimitValidator; |
110 | 107 | import org.opensearch.indices.SystemIndices; |
@@ -628,15 +625,18 @@ private ClusterState applyCreateIndexRequestWithV1Templates( |
628 | 625 | templates.stream().map(IndexTemplateMetadata::name).collect(Collectors.toList()) |
629 | 626 | ); |
630 | 627 |
|
631 | | - final List<Map<String, Object>> mappings = List.of(Collections.unmodifiableMap( |
632 | | - parseV1Mappings( |
633 | | - request.mappings(), |
634 | | - templates.stream().map(IndexTemplateMetadata::getMappings).collect(toList()), |
635 | | - xContentRegistry |
| 628 | + final List<Map<String, Object>> mappings = List.of( |
| 629 | + Collections.unmodifiableMap( |
| 630 | + parseV1Mappings( |
| 631 | + request.mappings(), |
| 632 | + templates.stream().map(IndexTemplateMetadata::getMappings).collect(toList()), |
| 633 | + xContentRegistry |
| 634 | + ) |
636 | 635 | ) |
637 | | - )); |
| 636 | + ); |
638 | 637 | Optional<Template> context = applyContext(request, currentState, mappings); |
639 | | - Settings aggregateSettings = Settings.builder().put(MetadataIndexTemplateService.resolveSettings(templates)) |
| 638 | + Settings aggregateSettings = Settings.builder() |
| 639 | + .put(MetadataIndexTemplateService.resolveSettings(templates)) |
640 | 640 | .put(context.isPresent() ? context.get().settings() : Settings.EMPTY) |
641 | 641 | .build(); |
642 | 642 |
|
@@ -711,7 +711,8 @@ private ClusterState applyCreateIndexRequestWithV2Template( |
711 | 711 | ); |
712 | 712 |
|
713 | 713 | Optional<Template> context = applyContext(request, currentState, mappings); |
714 | | - Settings aggregateSettings = Settings.builder().put(MetadataIndexTemplateService.resolveSettings(currentState.metadata(), templateName)) |
| 714 | + Settings aggregateSettings = Settings.builder() |
| 715 | + .put(MetadataIndexTemplateService.resolveSettings(currentState.metadata(), templateName)) |
715 | 716 | .put(context.isPresent() ? context.get().settings() : Settings.EMPTY) |
716 | 717 | .build(); |
717 | 718 |
|
@@ -755,8 +756,11 @@ private ClusterState applyCreateIndexRequestWithV2Template( |
755 | 756 | ); |
756 | 757 | } |
757 | 758 |
|
758 | | - private Optional<Template> applyContext(CreateIndexClusterStateUpdateRequest request, ClusterState currentState, |
759 | | - List<Map<String, Object>> mappings) throws IOException { |
| 759 | + private Optional<Template> applyContext( |
| 760 | + CreateIndexClusterStateUpdateRequest request, |
| 761 | + ClusterState currentState, |
| 762 | + List<Map<String, Object>> mappings |
| 763 | + ) throws IOException { |
760 | 764 | if (request.context() != null) { |
761 | 765 | String contextTemplate = MetadataIndexTemplateService.findContextTemplate(currentState.metadata(), request.context()); |
762 | 766 | ComponentTemplate componentTemplate = currentState.metadata().componentTemplates().get(contextTemplate); |
@@ -1734,7 +1738,6 @@ static void validateTranslogDurabilitySettings(Settings requestSettings, Cluster |
1734 | 1738 |
|
1735 | 1739 | } |
1736 | 1740 |
|
1737 | | - |
1738 | 1741 | static void validateContext(CreateIndexClusterStateUpdateRequest request, ClusterState clusterState) { |
1739 | 1742 | final boolean isContextAllowed = FeatureFlags.isEnabled(FeatureFlags.APPLICATION_BASED_CONFIGURATION_TEMPLATES); |
1740 | 1743 |
|
|
0 commit comments