public abstract class AnalyzerWrapper extends Analyzer
Analyzer
suitable for Analyzers which wrap
other Analyzers.
getWrappedAnalyzer(String)
allows the Analyzer
to wrap multiple Analyzers which are selected on a per field basis.
wrapComponents(String, Analyzer.TokenStreamComponents)
allows the
TokenStreamComponents of the wrapped Analyzer to then be wrapped
(such as adding a new TokenFilter
to form new TokenStreamComponents.Analyzer.GlobalReuseStrategy, Analyzer.PerFieldReuseStrategy, Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents
Modifier | Constructor and Description |
---|---|
protected |
AnalyzerWrapper()
Creates a new AnalyzerWrapper.
|
Modifier and Type | Method and Description |
---|---|
protected Analyzer.TokenStreamComponents |
createComponents(String fieldName,
Reader aReader)
Creates a new
Analyzer.TokenStreamComponents instance for this analyzer. |
int |
getOffsetGap(String fieldName)
Just like
Analyzer.getPositionIncrementGap(java.lang.String) , except for
Token offsets instead. |
int |
getPositionIncrementGap(String fieldName)
Invoked before indexing a IndexableField instance if
terms have already been added to that field.
|
protected abstract Analyzer |
getWrappedAnalyzer(String fieldName)
Retrieves the wrapped Analyzer appropriate for analyzing the field with
the given name
|
Reader |
initReader(String fieldName,
Reader reader)
Override this if you want to add a CharFilter chain.
|
protected abstract Analyzer.TokenStreamComponents |
wrapComponents(String fieldName,
Analyzer.TokenStreamComponents components)
Wraps / alters the given TokenStreamComponents, taken from the wrapped
Analyzer, to form new components.
|
close, tokenStream
protected AnalyzerWrapper()
Analyzer.ReuseStrategy
of
the wrapped Analyzers are unknown, Analyzer.PerFieldReuseStrategy
is assumedprotected abstract Analyzer getWrappedAnalyzer(String fieldName)
fieldName
- Name of the field which is to be analyzedprotected abstract Analyzer.TokenStreamComponents wrapComponents(String fieldName, Analyzer.TokenStreamComponents components)
fieldName
- Name of the field which is to be analyzedcomponents
- TokenStreamComponents taken from the wrapped Analyzerprotected final Analyzer.TokenStreamComponents createComponents(String fieldName, Reader aReader)
Analyzer
Analyzer.TokenStreamComponents
instance for this analyzer.createComponents
in class Analyzer
fieldName
- the name of the fields content passed to the
Analyzer.TokenStreamComponents
sink as a readeraReader
- the reader passed to the Tokenizer
constructorAnalyzer.TokenStreamComponents
for this analyzer.public final int getPositionIncrementGap(String fieldName)
Analyzer
getPositionIncrementGap
in class Analyzer
fieldName
- IndexableField name being indexed.Analyzer.tokenStream(String,Reader)
.
This value must be >= 0
.public final int getOffsetGap(String fieldName)
Analyzer
Analyzer.getPositionIncrementGap(java.lang.String)
, except for
Token offsets instead. By default this returns 1.
This method is only called if the field
produced at least one token for indexing.getOffsetGap
in class Analyzer
fieldName
- the field just indexedAnalyzer.tokenStream(String,Reader)
.
This value must be >= 0
.public final Reader initReader(String fieldName, Reader reader)
Analyzer
The default implementation returns reader
unchanged.
initReader
in class Analyzer
fieldName
- IndexableField name being indexedreader
- original ReaderCopyright © 2000-2013 Apache Software Foundation. All Rights Reserved.