Package org.elasticsearch.index.analysis
Class NamedAnalyzer
- java.lang.Object
-
- org.apache.lucene.analysis.Analyzer
-
- org.apache.lucene.analysis.AnalyzerWrapper
-
- org.apache.lucene.analysis.DelegatingAnalyzerWrapper
-
- org.elasticsearch.index.analysis.NamedAnalyzer
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class NamedAnalyzer extends DelegatingAnalyzerWrapper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.analysis.Analyzer
Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.analysis.Analyzer
GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY
-
-
Constructor Summary
Constructors Constructor Description NamedAnalyzer(String name, AnalyzerScope scope, Analyzer analyzer)NamedAnalyzer(NamedAnalyzer analyzer, int positionIncrementGap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Analyzeranalyzer()The actual analyzer.voidcheckAllowedInMode(AnalysisMode mode)Checks the wrapped analyzer for the provided restrictedAnalysisModeand throws an error if the analyzer is not allowed to run in that mode.voidclose()Frees persistent resources used by this Analyzerbooleanequals(Object o)AnalysisModegetAnalysisMode()Returns whether this analyzer can be updatedintgetPositionIncrementGap(String fieldName)Invoked before indexing a IndexableField instance if terms have already been added to that field.protected AnalyzergetWrappedAnalyzer(String fieldName)Retrieves the wrapped Analyzer appropriate for analyzing the field with the given nameinthashCode()Stringname()The name of the analyzer.AnalyzerScopescope()The scope of the analyzer.StringtoString()-
Methods inherited from class org.apache.lucene.analysis.DelegatingAnalyzerWrapper
wrapComponents, wrapReader, wrapReaderForNormalization, wrapTokenStreamForNormalization
-
Methods inherited from class org.apache.lucene.analysis.AnalyzerWrapper
attributeFactory, createComponents, getOffsetGap, initReader, initReaderForNormalization, normalize
-
Methods inherited from class org.apache.lucene.analysis.Analyzer
getReuseStrategy, getVersion, normalize, setVersion, tokenStream, tokenStream
-
-
-
-
Constructor Detail
-
NamedAnalyzer
public NamedAnalyzer(NamedAnalyzer analyzer, int positionIncrementGap)
-
NamedAnalyzer
public NamedAnalyzer(String name, AnalyzerScope scope, Analyzer analyzer)
-
-
Method Detail
-
name
public String name()
The name of the analyzer.
-
scope
public AnalyzerScope scope()
The scope of the analyzer.
-
getAnalysisMode
public AnalysisMode getAnalysisMode()
Returns whether this analyzer can be updated
-
analyzer
public Analyzer analyzer()
The actual analyzer.
-
getWrappedAnalyzer
protected Analyzer getWrappedAnalyzer(String fieldName)
Description copied from class:AnalyzerWrapperRetrieves the wrapped Analyzer appropriate for analyzing the field with the given name- Specified by:
getWrappedAnalyzerin classAnalyzerWrapper- Parameters:
fieldName- Name of the field which is to be analyzed- Returns:
- Analyzer for the field with the given name. Assumed to be non-null
-
getPositionIncrementGap
public int getPositionIncrementGap(String fieldName)
Description copied from class:AnalyzerInvoked before indexing a IndexableField instance if terms have already been added to that field. This allows custom analyzers to place an automatic position increment gap between IndexbleField instances using the same field name. The default value position increment gap is 0. With a 0 position increment gap and the typical default token position increment of 1, all terms in a field, including across IndexableField instances, are in successive positions, allowing exact PhraseQuery matches, for instance, across IndexableField instance boundaries.- Overrides:
getPositionIncrementGapin classAnalyzerWrapper- Parameters:
fieldName- IndexableField name being indexed.- Returns:
- position increment gap, added to the next token emitted from
Analyzer.tokenStream(String,Reader). This value must be>= 0.
-
checkAllowedInMode
public void checkAllowedInMode(AnalysisMode mode)
Checks the wrapped analyzer for the provided restrictedAnalysisModeand throws an error if the analyzer is not allowed to run in that mode. The error contains more detailed information about the offending filters that caused the analyzer to not be allowed in this mode.
-
-