CLucene - a full-featured, c++ search engine
API Documentation
#include <Analyzers.h>
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. | |
TokenStream * | tokenStream (const TCHAR *fieldName, lucene::util::Reader *reader) |
Creates a TokenStream which tokenizes all the text in the provided Reader. |
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.
lucene::analysis::PerFieldAnalyzerWrapper::PerFieldAnalyzerWrapper | ( | Analyzer * | defaultAnalyzer | ) |
Constructs with default analyzer.
defaultAnalyzer | Any fields not specifically defined to use a different analyzer will use the one provided here. |
virtual lucene::analysis::PerFieldAnalyzerWrapper::~PerFieldAnalyzerWrapper | ( | ) | [virtual] |
void lucene::analysis::PerFieldAnalyzerWrapper::addAnalyzer | ( | const TCHAR * | fieldName, | |
Analyzer * | analyzer | |||
) |
Defines an analyzer to use for the specified field.
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.