public final class PerFieldAnalyzerWrapper extends AnalyzerWrapper
PerFieldAnalyzerWrapper(Analyzer, java.util.Map)
to add non-default analyzers for fields.
Example usage:
Map<String,Analyzer> analyzerPerField = new HashMap<String,Analyzer>();
analyzerPerField.put("firstname", new KeywordAnalyzer());
analyzerPerField.put("lastname", new KeywordAnalyzer());
PerFieldAnalyzerWrapper aWrapper =
new PerFieldAnalyzerWrapper(new StandardAnalyzer(version), analyzerPerField);
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.
Analyzer.GlobalReuseStrategy, Analyzer.PerFieldReuseStrategy, Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents
GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
protected Analyzer |
getWrappedAnalyzer(String fieldName) |
String |
toString() |
createComponents, getOffsetGap, getPositionIncrementGap, initReader, wrapComponents, wrapReader
close, getReuseStrategy, tokenStream, tokenStream
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 fieldsprotected Analyzer getWrappedAnalyzer(String fieldName)
getWrappedAnalyzer
in class AnalyzerWrapper
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.