FileDocCategorySizeDatePackage
PerFieldAnalyzerWrapper.javaAPI DocApache Lucene 1.4.31990Tue Mar 30 00:48:00 BST 2004org.apache.lucene.analysis

PerFieldAnalyzerWrapper

public class PerFieldAnalyzerWrapper extends Analyzer
This analyzer is used to facilitate scenarios where different fields require different analysis techniques. Use {@link #addAnalyzer} to add a non-default analyzer on a field name basis. See TestPerFieldAnalyzerWrapper.java for example usage.

Fields Summary
private Analyzer
defaultAnalyzer
private Map
analyzerMap
Constructors Summary
public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer)
Constructs with default analyzer.

param
defaultAnalyzer Any fields not specifically defined to use a different analyzer will use the one provided here.



                           
     
    this.defaultAnalyzer = defaultAnalyzer;
  
Methods Summary
public voidaddAnalyzer(java.lang.String fieldName, org.apache.lucene.analysis.Analyzer analyzer)
Defines an analyzer to use for the specified field.

param
fieldName field name requiring a non-default analyzer.
param
analyzer non-default analyzer to use for field

    analyzerMap.put(fieldName, analyzer);
  
public org.apache.lucene.analysis.TokenStreamtokenStream(java.lang.String fieldName, java.io.Reader reader)

    Analyzer analyzer = (Analyzer) analyzerMap.get(fieldName);
    if (analyzer == null) {
      analyzer = defaultAnalyzer;
    }

    return analyzer.tokenStream(fieldName, reader);