use of org.opensearch.plugins.ScriptPlugin in project OpenSearch by opensearch-project.
the class MapperServiceTestCase method createMapperService.
/**
* Create a {@link MapperService} like we would for an index.
*/
protected final MapperService createMapperService(Version version, XContentBuilder mapping) throws IOException {
IndexMetadata meta = IndexMetadata.builder("index").settings(Settings.builder().put("index.version.created", version)).numberOfReplicas(0).numberOfShards(1).build();
IndexSettings indexSettings = new IndexSettings(meta, getIndexSettings());
MapperRegistry mapperRegistry = new IndicesModule(getPlugins().stream().filter(p -> p instanceof MapperPlugin).map(p -> (MapperPlugin) p).collect(toList())).getMapperRegistry();
ScriptModule scriptModule = new ScriptModule(Settings.EMPTY, getPlugins().stream().filter(p -> p instanceof ScriptPlugin).map(p -> (ScriptPlugin) p).collect(toList()));
ScriptService scriptService = new ScriptService(getIndexSettings(), scriptModule.engines, scriptModule.contexts);
SimilarityService similarityService = new SimilarityService(indexSettings, scriptService, emptyMap());
MapperService mapperService = new MapperService(indexSettings, createIndexAnalyzers(indexSettings), xContentRegistry(), similarityService, mapperRegistry, () -> {
throw new UnsupportedOperationException();
}, () -> true, scriptService);
merge(mapperService, mapping);
return mapperService;
}
Aggregations