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

Move getMetadataFields to IndexService #14586

Closed
Closed
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 @@ -33,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Updated the `indices.query.bool.max_clause_count` setting from being static to dynamically updateable ([#13568](https://github.com/opensearch-project/OpenSearch/pull/13568))
- Make the class CommunityIdProcessor final ([#14448](https://github.com/opensearch-project/OpenSearch/pull/14448))
- Allow @InternalApi annotation on classes not meant to be constructed outside of the OpenSearch core ([#14575](https://github.com/opensearch-project/OpenSearch/pull/14575))
- Move getMetadataFields to IndexService ([#14586](https://github.com/opensearch-project/OpenSearch/pull/14586))

### Deprecated

Expand Down
9 changes: 9 additions & 0 deletions server/src/main/java/org/opensearch/index/IndexService.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
private final CheckedFunction<DirectoryReader, DirectoryReader, IOException> readerWrapper;
private final IndexCache indexCache;
private final MapperService mapperService;
private final MapperRegistry mapperRegistry;
private final NamedXContentRegistry xContentRegistry;
private final NamedWriteableRegistry namedWriteableRegistry;
private final SimilarityService similarityService;
Expand Down Expand Up @@ -239,6 +240,7 @@ public IndexService(
this.circuitBreakerService = circuitBreakerService;
this.expressionResolver = expressionResolver;
this.valuesSourceRegistry = valuesSourceRegistry;
this.mapperRegistry = mapperRegistry;
if (needsMapperService(indexSettings, indexCreationContext)) {
assert indexAnalyzers != null;
this.mapperService = new MapperService(
Expand Down Expand Up @@ -1233,6 +1235,13 @@ private TimeValue getRefreshInterval() {
return clusterDefaultRefreshIntervalSupplier.get();
}

/**
* Returns a set containing the registered metadata fields
*/
public Set<String> getMetadataFields() {
return Collections.unmodifiableSet(mapperRegistry.getMetadataMapperParsers().keySet());
}

/**
* Base asynchronous task
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,6 @@ public boolean isMetadataField(String field) {
return mapperRegistry.isMetadataField(field);
}

/**
* Returns a set containing the registered metadata fields
*/
public Set<String> getMetadataFields() {
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 @@ -92,8 +92,8 @@ public void testTypeValidation() {
}

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

public void testPreflightUpdateDoesNotChangeMapping() throws Throwable {
Expand Down
Loading