add simplified extension point for plugins to add custom analysis components
This commit is contained in:
parent
5348c41924
commit
cec46d552d
|
@ -110,6 +110,12 @@ public class AnalysisModule extends AbstractModule {
|
|||
|
||||
private final LinkedList<AnalysisBinderProcessor> processors = Lists.newLinkedList();
|
||||
|
||||
private final Map<String, Class<? extends CharFilterFactory>> charFilters = Maps.newHashMap();
|
||||
private final Map<String, Class<? extends TokenFilterFactory>> tokenFilters = Maps.newHashMap();
|
||||
private final Map<String, Class<? extends TokenizerFactory>> tokenizers = Maps.newHashMap();
|
||||
private final Map<String, Class<? extends AnalyzerProvider>> analyzers = Maps.newHashMap();
|
||||
|
||||
|
||||
public AnalysisModule(Settings settings) {
|
||||
this(settings, null);
|
||||
}
|
||||
|
@ -130,6 +136,26 @@ public class AnalysisModule extends AbstractModule {
|
|||
return this;
|
||||
}
|
||||
|
||||
public AnalysisModule addCharFilter(String name, Class<? extends CharFilterFactory> charFilter) {
|
||||
charFilters.put(name, charFilter);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AnalysisModule addTokenFilter(String name, Class<? extends TokenFilterFactory> tokenFilter) {
|
||||
tokenFilters.put(name, tokenFilter);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AnalysisModule addTokenizerFactory(String name, Class<? extends TokenizerFactory> tokenizer) {
|
||||
tokenizers.put(name, tokenizer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AnalysisModule addAnalyzer(String name, Class<? extends AnalyzerProvider> analyzer) {
|
||||
analyzers.put(name, analyzer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
MapBinder<String, CharFilterFactoryFactory> charFilterBinder
|
||||
|
@ -141,6 +167,7 @@ public class AnalysisModule extends AbstractModule {
|
|||
for (AnalysisBinderProcessor processor : processors) {
|
||||
processor.processCharFilters(charFiltersBindings);
|
||||
}
|
||||
charFiltersBindings.charFilters.putAll(charFilters);
|
||||
|
||||
Map<String, Settings> charFiltersSettings = settings.getGroups("index.analysis.char_filter");
|
||||
for (Map.Entry<String, Settings> entry : charFiltersSettings.entrySet()) {
|
||||
|
@ -200,6 +227,7 @@ public class AnalysisModule extends AbstractModule {
|
|||
for (AnalysisBinderProcessor processor : processors) {
|
||||
processor.processTokenFilters(tokenFiltersBindings);
|
||||
}
|
||||
tokenFiltersBindings.tokenFilters.putAll(tokenFilters);
|
||||
|
||||
Map<String, Settings> tokenFiltersSettings = settings.getGroups("index.analysis.filter");
|
||||
for (Map.Entry<String, Settings> entry : tokenFiltersSettings.entrySet()) {
|
||||
|
@ -257,6 +285,7 @@ public class AnalysisModule extends AbstractModule {
|
|||
for (AnalysisBinderProcessor processor : processors) {
|
||||
processor.processTokenizers(tokenizersBindings);
|
||||
}
|
||||
tokenizersBindings.tokenizers.putAll(tokenizers);
|
||||
|
||||
Map<String, Settings> tokenizersSettings = settings.getGroups("index.analysis.tokenizer");
|
||||
for (Map.Entry<String, Settings> entry : tokenizersSettings.entrySet()) {
|
||||
|
@ -315,6 +344,7 @@ public class AnalysisModule extends AbstractModule {
|
|||
for (AnalysisBinderProcessor processor : processors) {
|
||||
processor.processAnalyzers(analyzersBindings);
|
||||
}
|
||||
analyzersBindings.analyzers.putAll(analyzers);
|
||||
|
||||
Map<String, Settings> analyzersSettings = settings.getGroups("index.analysis.analyzer");
|
||||
for (Map.Entry<String, Settings> entry : analyzersSettings.entrySet()) {
|
||||
|
|
Loading…
Reference in New Issue