Package org.elasticsearch.index.analysis
Class AnalysisRegistry
- java.lang.Object
-
- org.elasticsearch.index.analysis.AnalysisRegistry
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class AnalysisRegistry extends java.lang.Object implements java.io.Closeable
An internal registry for tokenizer, token filter, char filter and analyzer. This class exists per node and allows to create per-indexIndexAnalyzers
viabuild(IndexSettings)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
INDEX_ANALYSIS_CHAR_FILTER
static java.lang.String
INDEX_ANALYSIS_FILTER
static java.lang.String
INDEX_ANALYSIS_TOKENIZER
-
Constructor Summary
Constructors Constructor Description AnalysisRegistry(Environment environment, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<CharFilterFactory>> charFilters, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<TokenFilterFactory>> tokenFilters, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<TokenizerFactory>> tokenizers, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<AnalyzerProvider<?>>> analyzers, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<AnalyzerProvider<?>>> normalizers, java.util.Map<java.lang.String,PreConfiguredCharFilter> preConfiguredCharFilters, java.util.Map<java.lang.String,PreConfiguredTokenFilter> preConfiguredTokenFilters, java.util.Map<java.lang.String,PreConfiguredTokenizer> preConfiguredTokenizers, java.util.Map<java.lang.String,PreBuiltAnalyzerProviderFactory> preConfiguredAnalyzers)
-
Method Summary
Modifier and Type Method Description IndexAnalyzers
build(IndexSettings indexSettings)
Creates an index-levelIndexAnalyzers
from this registry using the given index settingsIndexAnalyzers
build(IndexSettings indexSettings, java.util.Map<java.lang.String,AnalyzerProvider<?>> analyzerProviders, java.util.Map<java.lang.String,AnalyzerProvider<?>> normalizerProviders, java.util.Map<java.lang.String,TokenizerFactory> tokenizerFactoryFactories, java.util.Map<java.lang.String,CharFilterFactory> charFilterFactoryFactories, java.util.Map<java.lang.String,TokenFilterFactory> tokenFilterFactoryFactories)
java.util.Map<java.lang.String,AnalyzerProvider<?>>
buildAnalyzerFactories(IndexSettings indexSettings)
java.util.Map<java.lang.String,CharFilterFactory>
buildCharFilterFactories(IndexSettings indexSettings)
java.util.Map<java.lang.String,AnalyzerProvider<?>>
buildNormalizerFactories(IndexSettings indexSettings)
java.util.Map<java.lang.String,TokenFilterFactory>
buildTokenFilterFactories(IndexSettings indexSettings)
java.util.Map<java.lang.String,TokenizerFactory>
buildTokenizerFactories(IndexSettings indexSettings)
void
close()
org.apache.lucene.analysis.Analyzer
getAnalyzer(java.lang.String analyzer)
Returns a registeredAnalyzer
provider by name ornull
if the analyzer was not registeredAnalysisModule.AnalysisProvider<CharFilterFactory>
getCharFilterProvider(java.lang.String charFilter)
Returns a registeredCharFilterFactory
provider by name ornull
if the char filter was not registeredAnalysisModule.AnalysisProvider<CharFilterFactory>
getCharFilterProvider(java.lang.String charFilter, IndexSettings indexSettings)
Returns a registeredCharFilterFactory
provider byIndexSettings
or a registeredCharFilterFactory
provider by predefined name ornull
if the charFilter was not registeredstatic Settings
getSettingsFromIndexSettings(IndexSettings indexSettings, java.lang.String groupName)
AnalysisModule.AnalysisProvider<TokenFilterFactory>
getTokenFilterProvider(java.lang.String tokenFilter)
Returns a registeredTokenFilterFactory
provider by name ornull
if the token filter was not registeredAnalysisModule.AnalysisProvider<TokenFilterFactory>
getTokenFilterProvider(java.lang.String tokenFilter, IndexSettings indexSettings)
Returns a registeredTokenFilterFactory
provider byIndexSettings
or a registeredTokenFilterFactory
provider by predefined name ornull
if the tokenFilter was not registeredAnalysisModule.AnalysisProvider<TokenizerFactory>
getTokenizerProvider(java.lang.String tokenizer)
Returns a registeredTokenizerFactory
provider by name ornull
if the tokenizer was not registeredAnalysisModule.AnalysisProvider<TokenizerFactory>
getTokenizerProvider(java.lang.String tokenizer, IndexSettings indexSettings)
Returns a registeredTokenizerFactory
provider byIndexSettings
or a registeredTokenizerFactory
provider by predefined name ornull
if the tokenizer was not registered
-
-
-
Field Detail
-
INDEX_ANALYSIS_CHAR_FILTER
public static final java.lang.String INDEX_ANALYSIS_CHAR_FILTER
- See Also:
- Constant Field Values
-
INDEX_ANALYSIS_FILTER
public static final java.lang.String INDEX_ANALYSIS_FILTER
- See Also:
- Constant Field Values
-
INDEX_ANALYSIS_TOKENIZER
public static final java.lang.String INDEX_ANALYSIS_TOKENIZER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AnalysisRegistry
public AnalysisRegistry(Environment environment, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<CharFilterFactory>> charFilters, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<TokenFilterFactory>> tokenFilters, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<TokenizerFactory>> tokenizers, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<AnalyzerProvider<?>>> analyzers, java.util.Map<java.lang.String,AnalysisModule.AnalysisProvider<AnalyzerProvider<?>>> normalizers, java.util.Map<java.lang.String,PreConfiguredCharFilter> preConfiguredCharFilters, java.util.Map<java.lang.String,PreConfiguredTokenFilter> preConfiguredTokenFilters, java.util.Map<java.lang.String,PreConfiguredTokenizer> preConfiguredTokenizers, java.util.Map<java.lang.String,PreBuiltAnalyzerProviderFactory> preConfiguredAnalyzers)
-
-
Method Detail
-
getSettingsFromIndexSettings
public static Settings getSettingsFromIndexSettings(IndexSettings indexSettings, java.lang.String groupName)
- Parameters:
indexSettings
- an index settingsgroupName
- tokenizer/token filter/char filter name- Returns:
Settings
-
getTokenizerProvider
public AnalysisModule.AnalysisProvider<TokenizerFactory> getTokenizerProvider(java.lang.String tokenizer)
Returns a registeredTokenizerFactory
provider by name ornull
if the tokenizer was not registered
-
getTokenFilterProvider
public AnalysisModule.AnalysisProvider<TokenFilterFactory> getTokenFilterProvider(java.lang.String tokenFilter)
Returns a registeredTokenFilterFactory
provider by name ornull
if the token filter was not registered
-
getCharFilterProvider
public AnalysisModule.AnalysisProvider<CharFilterFactory> getCharFilterProvider(java.lang.String charFilter)
Returns a registeredCharFilterFactory
provider by name ornull
if the char filter was not registered
-
getAnalyzer
public org.apache.lucene.analysis.Analyzer getAnalyzer(java.lang.String analyzer) throws java.io.IOException
Returns a registeredAnalyzer
provider by name ornull
if the analyzer was not registered- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
build
public IndexAnalyzers build(IndexSettings indexSettings) throws java.io.IOException
Creates an index-levelIndexAnalyzers
from this registry using the given index settings- Throws:
java.io.IOException
-
buildTokenFilterFactories
public java.util.Map<java.lang.String,TokenFilterFactory> buildTokenFilterFactories(IndexSettings indexSettings) throws java.io.IOException
- Throws:
java.io.IOException
-
buildTokenizerFactories
public java.util.Map<java.lang.String,TokenizerFactory> buildTokenizerFactories(IndexSettings indexSettings) throws java.io.IOException
- Throws:
java.io.IOException
-
buildCharFilterFactories
public java.util.Map<java.lang.String,CharFilterFactory> buildCharFilterFactories(IndexSettings indexSettings) throws java.io.IOException
- Throws:
java.io.IOException
-
buildAnalyzerFactories
public java.util.Map<java.lang.String,AnalyzerProvider<?>> buildAnalyzerFactories(IndexSettings indexSettings) throws java.io.IOException
- Throws:
java.io.IOException
-
buildNormalizerFactories
public java.util.Map<java.lang.String,AnalyzerProvider<?>> buildNormalizerFactories(IndexSettings indexSettings) throws java.io.IOException
- Throws:
java.io.IOException
-
getTokenizerProvider
public AnalysisModule.AnalysisProvider<TokenizerFactory> getTokenizerProvider(java.lang.String tokenizer, IndexSettings indexSettings)
Returns a registeredTokenizerFactory
provider byIndexSettings
or a registeredTokenizerFactory
provider by predefined name ornull
if the tokenizer was not registered- Parameters:
tokenizer
- global or defined tokenizer nameindexSettings
- an index settings- Returns:
TokenizerFactory
provider ornull
-
getTokenFilterProvider
public AnalysisModule.AnalysisProvider<TokenFilterFactory> getTokenFilterProvider(java.lang.String tokenFilter, IndexSettings indexSettings)
Returns a registeredTokenFilterFactory
provider byIndexSettings
or a registeredTokenFilterFactory
provider by predefined name ornull
if the tokenFilter was not registered- Parameters:
tokenFilter
- global or defined tokenFilter nameindexSettings
- an index settings- Returns:
TokenFilterFactory
provider ornull
-
getCharFilterProvider
public AnalysisModule.AnalysisProvider<CharFilterFactory> getCharFilterProvider(java.lang.String charFilter, IndexSettings indexSettings)
Returns a registeredCharFilterFactory
provider byIndexSettings
or a registeredCharFilterFactory
provider by predefined name ornull
if the charFilter was not registered- Parameters:
charFilter
- global or defined charFilter nameindexSettings
- an index settings- Returns:
CharFilterFactory
provider ornull
-
build
public IndexAnalyzers build(IndexSettings indexSettings, java.util.Map<java.lang.String,AnalyzerProvider<?>> analyzerProviders, java.util.Map<java.lang.String,AnalyzerProvider<?>> normalizerProviders, java.util.Map<java.lang.String,TokenizerFactory> tokenizerFactoryFactories, java.util.Map<java.lang.String,CharFilterFactory> charFilterFactoryFactories, java.util.Map<java.lang.String,TokenFilterFactory> tokenFilterFactoryFactories)
-
-