use of org.opensearch.plugins.MapperPlugin in project OpenSearch by opensearch-project.
the class IndicesModuleTests method testNoOpFieldPredicate.
public void testNoOpFieldPredicate() {
List<MapperPlugin> mapperPlugins = Arrays.asList(new MapperPlugin() {
@Override
public Function<String, Predicate<String>> getFieldFilter() {
return MapperPlugin.NOOP_FIELD_FILTER;
}
}, new MapperPlugin() {
@Override
public Function<String, Predicate<String>> getFieldFilter() {
return index -> index.equals("hidden_index") ? field -> false : MapperPlugin.NOOP_FIELD_PREDICATE;
}
}, new MapperPlugin() {
@Override
public Function<String, Predicate<String>> getFieldFilter() {
return index -> index.equals("filtered") ? field -> field.equals("visible") : MapperPlugin.NOOP_FIELD_PREDICATE;
}
});
IndicesModule indicesModule = new IndicesModule(mapperPlugins);
MapperRegistry mapperRegistry = indicesModule.getMapperRegistry();
Function<String, Predicate<String>> fieldFilter = mapperRegistry.getFieldFilter();
assertSame(MapperPlugin.NOOP_FIELD_PREDICATE, fieldFilter.apply(randomAlphaOfLengthBetween(3, 7)));
assertNotSame(MapperPlugin.NOOP_FIELD_PREDICATE, fieldFilter.apply("hidden_index"));
assertNotSame(MapperPlugin.NOOP_FIELD_PREDICATE, fieldFilter.apply("filtered"));
}
use of org.opensearch.plugins.MapperPlugin in project OpenSearch by opensearch-project.
the class IndicesModuleTests method testDuplicateOtherPluginMetadataMapper.
public void testDuplicateOtherPluginMetadataMapper() {
MapperPlugin plugin = new MapperPlugin() {
@Override
public Map<String, MetadataFieldMapper.TypeParser> getMetadataMappers() {
return Collections.singletonMap("foo", PARSER);
}
};
List<MapperPlugin> plugins = Arrays.asList(plugin, plugin);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new IndicesModule(plugins));
assertThat(e.getMessage(), containsString("already registered"));
}
use of org.opensearch.plugins.MapperPlugin in project OpenSearch by opensearch-project.
the class IndicesModuleTests method testDuplicateOtherPluginMapper.
public void testDuplicateOtherPluginMapper() {
MapperPlugin plugin = new MapperPlugin() {
@Override
public Map<String, Mapper.TypeParser> getMappers() {
return Collections.singletonMap("foo", new FakeMapperParser());
}
};
List<MapperPlugin> plugins = Arrays.asList(plugin, plugin);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new IndicesModule(plugins));
assertThat(e.getMessage(), containsString("already registered"));
}
use of org.opensearch.plugins.MapperPlugin in project OpenSearch by opensearch-project.
the class IndicesModuleTests method testDefaultFieldFilterIsNoOp.
public void testDefaultFieldFilterIsNoOp() {
int numPlugins = randomIntBetween(0, 10);
List<MapperPlugin> mapperPlugins = new ArrayList<>(numPlugins);
for (int i = 0; i < numPlugins; i++) {
mapperPlugins.add(new MapperPlugin() {
});
}
IndicesModule indicesModule = new IndicesModule(mapperPlugins);
Function<String, Predicate<String>> fieldFilter = indicesModule.getMapperRegistry().getFieldFilter();
assertSame(MapperPlugin.NOOP_FIELD_FILTER, fieldFilter);
}
use of org.opensearch.plugins.MapperPlugin in project OpenSearch by opensearch-project.
the class IndicesModuleTests method testDuplicateBuiltinMapper.
public void testDuplicateBuiltinMapper() {
List<MapperPlugin> plugins = Arrays.asList(new MapperPlugin() {
@Override
public Map<String, Mapper.TypeParser> getMappers() {
return Collections.singletonMap(TextFieldMapper.CONTENT_TYPE, new FakeMapperParser());
}
});
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new IndicesModule(plugins));
assertThat(e.getMessage(), containsString("already registered"));
}
Aggregations