public class PerFieldAnalyzer
extends org.apache.lucene.analysis.Analyzer
#addAnalyzer
to add a non-default Analyzer or addAnalyzersInBundle(java.util.ResourceBundle)
to
provide a ResourceBundle to configure Analyzers on a field name basis. The ResourceBundle should contain
className=field1,field2,... pairs, where the field names are a comma-separated list, for example:
org.dlese.dpc.index.analysis.SnowballAnalyzer=stems,titlestems
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KEYWORD_ANALYZER |
static java.lang.String |
STEMS_ANALYZER |
static java.lang.String |
TEXT_ANALYZER |
Constructor and Description |
---|
PerFieldAnalyzer()
Constructs using a
StandardAnalyzer as the default for fields
not otherwise configured. |
PerFieldAnalyzer(org.apache.lucene.analysis.Analyzer defaultAnalyzer)
Constructs with the given Analyzer to use as a default for fields not otherwise configured.
|
Modifier and Type | Method and Description |
---|---|
void |
addAnalyzersInBundle(java.util.ResourceBundle fieldAnalyzerBundle)
Adds the Analyzers to use for given fields, using the field=className pairs provided in the
ResourceBundle, overrridding any previous ones if they existed.
|
boolean |
containsAnalyzer(java.lang.String fieldName)
Determines if an Analyzer is configured for the given field.
|
org.apache.lucene.analysis.Analyzer |
getAnalyzer(java.lang.String fieldName)
Gets the Analyzer configured for the given field, or null if none exists.
|
org.apache.lucene.analysis.Analyzer |
getDefaultAnalyzer()
Gets the default Analyzer being used.
|
org.apache.lucene.analysis.Analyzer |
removeAnalyzer(java.lang.String fieldName)
Removes the Analyzer that is configured for the given field, if one exists.
|
void |
setAnalyzer(java.lang.String fieldName,
java.lang.String analyzerClassName)
Sets the Analyzer to use for the specified search field, overridding the previous one if it existed.
|
void |
setDefaultAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
Sets the default Analyzer to use from here forth.
|
org.apache.lucene.analysis.TokenStream |
tokenStream(java.lang.String fieldName,
java.io.Reader reader)
Generates a token stream for the given field.
|
java.lang.String |
toString() |
public static final java.lang.String TEXT_ANALYZER
public static final java.lang.String KEYWORD_ANALYZER
public static final java.lang.String STEMS_ANALYZER
public PerFieldAnalyzer(org.apache.lucene.analysis.Analyzer defaultAnalyzer)
StandardAnalyzer
will be used as the default.defaultAnalyzer
- Any fields not specifically defined to use a different analyzer will use the one
provided here.public PerFieldAnalyzer()
StandardAnalyzer
as the default for fields
not otherwise configured.public void setAnalyzer(java.lang.String fieldName, java.lang.String analyzerClassName) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
fieldName
- field name requiring a non-default analyzer.analyzerClassName
- Name of Analyzer class to use for the fieldjava.lang.ClassNotFoundException
- If errorjava.lang.InstantiationException
- If errorjava.lang.IllegalAccessException
- If errorpublic java.lang.String toString()
toString
in class java.lang.Object
public void addAnalyzersInBundle(java.util.ResourceBundle fieldAnalyzerBundle) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
org.dlese.dpc.index.analysis.SnowballAnalyzer=stems,titlestems
fieldAnalyzerBundle
- A resource bundle containing className=field1,field2,etc. pairsjava.lang.ClassNotFoundException
- If errorjava.lang.InstantiationException
- If errorjava.lang.IllegalAccessException
- If errorpublic org.apache.lucene.analysis.Analyzer getAnalyzer(java.lang.String fieldName)
fieldName
- The field namepublic org.apache.lucene.analysis.Analyzer getDefaultAnalyzer()
public void setDefaultAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
analyzer
- The new default Analyzerpublic boolean containsAnalyzer(java.lang.String fieldName)
fieldName
- The field namepublic org.apache.lucene.analysis.Analyzer removeAnalyzer(java.lang.String fieldName)
fieldName
- The field namepublic org.apache.lucene.analysis.TokenStream tokenStream(java.lang.String fieldName, java.io.Reader reader)
tokenStream
in class org.apache.lucene.analysis.Analyzer
fieldName
- The field namereader
- The Reader