Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getMetadataFields to MapperService #13819

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Make outbound side of transport protocol dependent ([#13293](https://github.com/opensearch-project/OpenSearch/pull/13293))
- [Remote Store] Add dynamic cluster settings to set timeout for segments upload to Remote Store ([#13679](https://github.com/opensearch-project/OpenSearch/pull/13679))
- [Remote Store] Upload translog checkpoint as object metadata to translog.tlog([#13637](https://github.com/opensearch-project/OpenSearch/pull/13637))
- Add getMetadataFields to MapperService ([#13819](https://github.com/opensearch-project/OpenSearch/pull/13819))

### Dependencies
- Bump `com.github.spullara.mustache.java:compiler` from 0.9.10 to 0.9.13 ([#13329](https://github.com/opensearch-project/OpenSearch/pull/13329), [#13559](https://github.com/opensearch-project/OpenSearch/pull/13559))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,13 @@ public boolean isMetadataField(String field) {
return mapperRegistry.isMetadataField(field);
}

/**
* Returns a set containing the registered metadata fields
*/
public Set<String> getMetadataFields() {
cwperks marked this conversation as resolved.
Show resolved Hide resolved
return Collections.unmodifiableSet(mapperRegistry.getMetadataMapperParsers().keySet());
}

/**
* An analyzer wrapper that can lookup fields within the index mappings
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.opensearch.index.mapper.KeywordFieldMapper.KeywordFieldType;
import org.opensearch.index.mapper.MapperService.MergeReason;
import org.opensearch.index.mapper.NumberFieldMapper.NumberFieldType;
import org.opensearch.indices.IndicesModule;
import org.opensearch.indices.InvalidTypeNameException;
import org.opensearch.indices.analysis.AnalysisModule.AnalysisProvider;
import org.opensearch.plugins.AnalysisPlugin;
Expand Down Expand Up @@ -90,6 +91,11 @@ public void testTypeValidation() {
MapperService.validateTypeName("_doc"); // no exception
}

public void testGetMetadataFieldsReturnsExpectedSet() throws Throwable {
final MapperService mapperService = createIndex("test1").mapperService();
assertEquals(mapperService.getMetadataFields(), IndicesModule.getBuiltInMetadataFields());
}

public void testPreflightUpdateDoesNotChangeMapping() throws Throwable {
final MapperService mapperService = createIndex("test1").mapperService();
final CompressedXContent mapping = createMappingSpecifyingNumberOfFields(1);
Expand Down
Loading