Defining a new analyzer provider forces pakcage name of the provider to begin with org.elasticsearch

(erez) #1

My elasticsearch properties define my own type:

When I run it I get a org.elasticsearch.common.settings.SettingsException:

Caused by: org.elasticsearch.common.settings.SettingsException: Component [] does not start with prefix [org.elasticsearch] at org.elasticsearch.common.settings.ImmutableSettings.getComponentSettings( at org.elasticsearch.common.settings.ImmutableSettings.getComponentSettings( at org.elasticsearch.index.AbstractIndexComponent.( at org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider.( ...

<raw>@Override public Settings getComponentSettings(Class component) {
    return getComponentSettings("org.elasticsearch", component);

@Override public Settings getComponentSettings(String prefix, Class component) {
    String type = component.getName();
    if (!type.startsWith(prefix)) {
        throw new SettingsException("Component [" + type + "] does not start with prefix [" + prefix + "]");
    String settingPrefix = type.substring(prefix.length() + 1); // 1 for the '.'
    settingPrefix = settingPrefix.substring(0, settingPrefix.length() - component.getSimpleName().length()); // remove the simple class name (keep the dot)
    return getByPrefix(settingPrefix);

If I change my provider's package to begin with org.elasticsearch then everything works fine. However this kind of restriction is suspicious in nature. Why should I be required to define this class in this package and not in my own packages?

(system) #2