CLucene - a full-featured, c++ search engine
API Documentation


lucene::analysis::PerFieldAnalyzerWrapper Class Reference

This analyzer is used to facilitate scenarios where different fields require different analysis techniques. More...

#include <Analyzers.h>

Inheritance diagram for lucene::analysis::PerFieldAnalyzerWrapper:

lucene::analysis::Analyzer

Public Member Functions

 PerFieldAnalyzerWrapper (Analyzer *defaultAnalyzer)
 Constructs with default analyzer.
virtual ~PerFieldAnalyzerWrapper ()
void addAnalyzer (const TCHAR *fieldName, Analyzer *analyzer)
 Defines an analyzer to use for the specified field.
TokenStreamtokenStream (const TCHAR *fieldName, lucene::util::Reader *reader)
 Creates a TokenStream which tokenizes all the text in the provided Reader.

Detailed Description

This analyzer is used to facilitate scenarios where different fields require different analysis techniques.

Use addAnalyzer 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 & Destructor Documentation

lucene::analysis::PerFieldAnalyzerWrapper::PerFieldAnalyzerWrapper ( Analyzer defaultAnalyzer  ) 

Constructs with default analyzer.

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

virtual lucene::analysis::PerFieldAnalyzerWrapper::~PerFieldAnalyzerWrapper (  )  [virtual]


Member Function Documentation

void lucene::analysis::PerFieldAnalyzerWrapper::addAnalyzer ( const TCHAR *  fieldName,
Analyzer analyzer 
)

Defines an analyzer to use for the specified field.

Parameters:
fieldName field name requiring a non-default analyzer
analyzer non-default analyzer to use for field

TokenStream* lucene::analysis::PerFieldAnalyzerWrapper::tokenStream ( const TCHAR *  fieldName,
lucene::util::Reader reader 
) [virtual]

Creates a TokenStream which tokenizes all the text in the provided Reader.

Default implementation forwards to tokenStream(Reader) for compatibility with older version. Override to allow Analyzer to choose strategy based on document and/or field. Must be able to handle null field name for backward compatibility.

Implements lucene::analysis::Analyzer.


The documentation for this class was generated from the following file:

clucene.sourceforge.net