Skip to content

Commit

Permalink
Add changelog
Browse files Browse the repository at this point in the history
Signed-off-by: Mohit Godwani <[email protected]>
  • Loading branch information
mgodwan committed Aug 21, 2024
1 parent fbb28f2 commit 929d241
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Support filtering on a large list encoded by bitmap ([#14774](https://github.com/opensearch-project/OpenSearch/pull/14774))
- Add slice execution listeners to SearchOperationListener interface ([#15153](https://github.com/opensearch-project/OpenSearch/pull/15153))
- Adding access to noSubMatches and noOverlappingMatches in Hyphenation ([#13895](https://github.com/opensearch-project/OpenSearch/pull/13895))
- Add index creation using the context field ([#15290](https://github.com/opensearch-project/OpenSearch/pull/15290))

### Dependencies
- Bump `netty` from 4.1.111.Final to 4.1.112.Final ([#15081](https://github.com/opensearch-project/OpenSearch/pull/15081))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
import org.opensearch.index.mapper.DocumentMapper;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.index.mapper.MapperService.MergeReason;
import org.opensearch.index.mapper.Mapping;
import org.opensearch.index.query.QueryShardContext;
import org.opensearch.index.remote.RemoteStoreCustomMetadataResolver;
import org.opensearch.index.remote.RemoteStoreEnums.PathHashAlgorithm;
Expand All @@ -101,10 +100,8 @@
import org.opensearch.index.translog.Translog;
import org.opensearch.indices.IndexCreationException;
import org.opensearch.indices.IndicesService;
import org.opensearch.indices.InvalidAliasNameException;
import org.opensearch.indices.InvalidIndexContextException;
import org.opensearch.indices.InvalidIndexNameException;
import org.opensearch.indices.InvalidIndexTemplateException;
import org.opensearch.indices.RemoteStoreSettings;
import org.opensearch.indices.ShardLimitValidator;
import org.opensearch.indices.SystemIndices;
Expand Down Expand Up @@ -628,15 +625,18 @@ private ClusterState applyCreateIndexRequestWithV1Templates(
templates.stream().map(IndexTemplateMetadata::name).collect(Collectors.toList())
);

final List<Map<String, Object>> mappings = List.of(Collections.unmodifiableMap(
parseV1Mappings(
request.mappings(),
templates.stream().map(IndexTemplateMetadata::getMappings).collect(toList()),
xContentRegistry
final List<Map<String, Object>> mappings = List.of(
Collections.unmodifiableMap(
parseV1Mappings(
request.mappings(),
templates.stream().map(IndexTemplateMetadata::getMappings).collect(toList()),
xContentRegistry
)
)
));
);
Optional<Template> context = applyContext(request, currentState, mappings);
Settings aggregateSettings = Settings.builder().put(MetadataIndexTemplateService.resolveSettings(templates))
Settings aggregateSettings = Settings.builder()
.put(MetadataIndexTemplateService.resolveSettings(templates))
.put(context.isPresent() ? context.get().settings() : Settings.EMPTY)
.build();

Expand Down Expand Up @@ -711,7 +711,8 @@ private ClusterState applyCreateIndexRequestWithV2Template(
);

Optional<Template> context = applyContext(request, currentState, mappings);
Settings aggregateSettings = Settings.builder().put(MetadataIndexTemplateService.resolveSettings(currentState.metadata(), templateName))
Settings aggregateSettings = Settings.builder()
.put(MetadataIndexTemplateService.resolveSettings(currentState.metadata(), templateName))
.put(context.isPresent() ? context.get().settings() : Settings.EMPTY)
.build();

Expand Down Expand Up @@ -755,8 +756,11 @@ private ClusterState applyCreateIndexRequestWithV2Template(
);
}

private Optional<Template> applyContext(CreateIndexClusterStateUpdateRequest request, ClusterState currentState,
List<Map<String, Object>> mappings) throws IOException {
private Optional<Template> applyContext(
CreateIndexClusterStateUpdateRequest request,
ClusterState currentState,
List<Map<String, Object>> mappings
) throws IOException {
if (request.context() != null) {
String contextTemplate = MetadataIndexTemplateService.findContextTemplate(currentState.metadata(), request.context());
ComponentTemplate componentTemplate = currentState.metadata().componentTemplates().get(contextTemplate);
Expand Down Expand Up @@ -1734,7 +1738,6 @@ static void validateTranslogDurabilitySettings(Settings requestSettings, Cluster

}


static void validateContext(CreateIndexClusterStateUpdateRequest request, ClusterState clusterState) {
final boolean isContextAllowed = FeatureFlags.isEnabled(FeatureFlags.APPLICATION_BASED_CONFIGURATION_TEMPLATES);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@

import org.opensearch.OpenSearchException;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.rest.RestStatus;

import java.io.IOException;

/**
* Exception when the context provided in the creation of an index is invalid.
*/
public class InvalidIndexContextException extends OpenSearchException {

/**
*
* @param indexName name of the index
* @param name context name provided
* @param description error message
*/
public InvalidIndexContextException(String indexName, String name, String description) {
super("Invalid context name [{}] provide for index: {}, [{}]", name, indexName, description);
}
Expand Down

0 comments on commit 929d241

Please sign in to comment.