|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.analysis.Analyzer org.apache.lucene.analysis.PerFieldAnalyzerWrapper
public final class PerFieldAnalyzerWrapper
This analyzer is used to facilitate scenarios where different
fields require different analysis techniques. Use addAnalyzer(java.lang.String, org.apache.lucene.analysis.Analyzer)
to add a non-default analyzer on a field name basis.
Example usage:
PerFieldAnalyzerWrapper aWrapper = new PerFieldAnalyzerWrapper(new StandardAnalyzer()); aWrapper.addAnalyzer("firstname", new KeywordAnalyzer()); aWrapper.addAnalyzer("lastname", new KeywordAnalyzer());
In this example, StandardAnalyzer will be used for all fields except "firstname" and "lastname", for which KeywordAnalyzer will be used.
A PerFieldAnalyzerWrapper can be used like any other analyzer, for both indexing and query parsing.
Constructor Summary | |
---|---|
PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer)
Constructs with default analyzer. |
|
PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer,
Map<String,Analyzer> fieldAnalyzers)
Constructs with default analyzer and a map of analyzers to use for specific fields. |
Method Summary | |
---|---|
void |
addAnalyzer(String fieldName,
Analyzer analyzer)
Defines an analyzer to use for the specified field. |
int |
getOffsetGap(Fieldable field)
Return the offsetGap from the analyzer assigned to field |
int |
getPositionIncrementGap(String fieldName)
Return the positionIncrementGap from the analyzer assigned to fieldName |
TokenStream |
reusableTokenStream(String fieldName,
Reader reader)
Creates a TokenStream that is allowed to be re-used from the previous time that the same thread called this method. |
TokenStream |
tokenStream(String fieldName,
Reader reader)
Creates a TokenStream which tokenizes all the text in the provided Reader. |
String |
toString()
|
Methods inherited from class org.apache.lucene.analysis.Analyzer |
---|
close, getPreviousTokenStream, setPreviousTokenStream |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer)
defaultAnalyzer
- Any fields not specifically
defined to use a different analyzer will use the one provided here.public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer, Map<String,Analyzer> fieldAnalyzers)
defaultAnalyzer
- Any fields not specifically
defined to use a different analyzer will use the one provided here.fieldAnalyzers
- a Map (String field name to the Analyzer) to be
used for those fieldsMethod Detail |
---|
public void addAnalyzer(String fieldName, Analyzer analyzer)
fieldName
- field name requiring a non-default analyzeranalyzer
- non-default analyzer to use for fieldpublic TokenStream tokenStream(String fieldName, Reader reader)
Analyzer
tokenStream
in class Analyzer
public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException
Analyzer
reusableTokenStream
in class Analyzer
IOException
public int getPositionIncrementGap(String fieldName)
getPositionIncrementGap
in class Analyzer
fieldName
- Fieldable name being indexed.
Analyzer.tokenStream(String,Reader)
public int getOffsetGap(Fieldable field)
getOffsetGap
in class Analyzer
field
- the field just indexed
Analyzer.tokenStream(String,Reader)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |