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

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes
Lucene::PerFieldAnalyzerWrapper Class Reference

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. More...

`#include <PerFieldAnalyzerWrapper.h>`

Inheritance diagram for Lucene::PerFieldAnalyzerWrapper:

## Public Member Functions

| PerFieldAnalyzerWrapper (const AnalyzerPtr &defaultAnalyzer)
| Constructs with default analyzer.
| PerFieldAnalyzerWrapper (const AnalyzerPtr &defaultAnalyzer, MapStringAnalyzer fieldAnalyzers)
| Constructs with default analyzer and a map of analyzers to use for specific fields.
virtual | ~PerFieldAnalyzerWrapper ()
virtual String | getClassName ()
boost::shared_ptr< PerFieldAnalyzerWrapper > | shared_from_this ()
void | addAnalyzer (const String &fieldName, const AnalyzerPtr &analyzer)
| Defines an analyzer to use for the specified field.
virtual TokenStreamPtr | tokenStream (const String &fieldName, const ReaderPtr &reader)
| Creates a TokenStream which tokenizes all the text in the provided Reader. Must be able to handle null field name for backward compatibility.
virtual TokenStreamPtr | reusableTokenStream (const String &fieldName, const ReaderPtr &reader)
| Creates a TokenStream that is allowed to be re-used from the previous time that the same thread called this method. Callers that do not need to use more than one TokenStream at the same time from this analyzer should use this method for better performance.
virtual int32_t | getPositionIncrementGap (const String &fieldName)
| Return the positionIncrementGap from the analyzer assigned to fieldName.
virtual int32_t | getOffsetGap (const FieldablePtr &field)
| Return the offsetGap from the analyzer assigned to field.
virtual String | toString ()
| Returns a string representation of the object.
Public Member Functions inherited from Lucene::Analyzer
virtual | ~Analyzer ()
boost::shared_ptr< Analyzer > | shared_from_this ()
virtual void | close ()
| Frees persistent resources used by this Analyzer.
Public Member Functions inherited from Lucene::LuceneObject
virtual | ~LuceneObject ()
virtual void | initialize ()
| Called directly after instantiation to create objects that depend on this object being fully constructed.
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object.
virtual int32_t | hashCode ()
| Return hash code for this object.
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal.
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects.
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock.
virtual LuceneSignalPtr | getSignal ()
| Return this object signal.
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout.
virtual void | unlock ()
| Unlock this object.
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread.
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout.
virtual void | notifyAll ()
| Notify all threads waiting for signal.

## Static Public Member Functions

static String | _getClassName ()
Static Public Member Functions inherited from Lucene::Analyzer
static String | _getClassName ()

## Protected Attributes

AnalyzerPtr | defaultAnalyzer
MapStringAnalyzer | analyzerMap
Protected Attributes inherited from Lucene::Analyzer
CloseableThreadLocal< LuceneObject > | tokenStreams
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Additional Inherited Members

Protected Member Functions inherited from Lucene::Analyzer
virtual LuceneObjectPtr | getPreviousTokenStream ()
| Used by Analyzers that implement reusableTokenStream to retrieve previously saved TokenStreams for re-use by the same thread.
virtual void | setPreviousTokenStream (const LuceneObjectPtr &stream)
| Used by Analyzers that implement reusableTokenStream to save a TokenStream for later re-use by the same thread.
Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## 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:

    PerFieldAnalyzerWrapperPtr aWrapper = newLucene<PerFieldAnalyzerWrapper>(newLucene<StandardAnalyzer>());
    aWrapper->addAnalyzer(L"firstname", newLucene<KeywordAnalyzer>());
    aWrapper->addAnalyzer(L"lastname", newLucene<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

## ◆ PerFieldAnalyzerWrapper() [1/2]

Lucene::PerFieldAnalyzerWrapper::PerFieldAnalyzerWrapper | ( | const AnalyzerPtr & | defaultAnalyzer | ) |

Constructs with default analyzer.

Parameters

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

## ◆ PerFieldAnalyzerWrapper() [2/2]

Lucene::PerFieldAnalyzerWrapper::PerFieldAnalyzerWrapper | ( | const AnalyzerPtr & | defaultAnalyzer,
|  | MapStringAnalyzer | fieldAnalyzers
| ) |  |

Constructs with default analyzer and a map of analyzers to use for specific fields.

Parameters

  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 fields

## ◆ ~PerFieldAnalyzerWrapper()

virtual Lucene::PerFieldAnalyzerWrapper::~PerFieldAnalyzerWrapper | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

static String Lucene::PerFieldAnalyzerWrapper::_getClassName | ( |  | ) |

inline static

## ◆ addAnalyzer()

void Lucene::PerFieldAnalyzerWrapper::addAnalyzer | ( | const String & | fieldName,
|  | const AnalyzerPtr & | 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

## ◆ getClassName()

virtual String Lucene::PerFieldAnalyzerWrapper::getClassName | ( |  | ) |

inline virtual

Reimplemented from Lucene::Analyzer.

## ◆ getOffsetGap()

virtual int32_t Lucene::PerFieldAnalyzerWrapper::getOffsetGap | ( | const FieldablePtr & | field | ) |

virtual

Return the offsetGap from the analyzer assigned to field.

Reimplemented from Lucene::Analyzer.

## ◆ getPositionIncrementGap()

virtual int32_t Lucene::PerFieldAnalyzerWrapper::getPositionIncrementGap | ( | const String & | fieldName | ) |

virtual

Return the positionIncrementGap from the analyzer assigned to fieldName.

Reimplemented from Lucene::Analyzer.

## ◆ reusableTokenStream()

virtual TokenStreamPtr Lucene::PerFieldAnalyzerWrapper::reusableTokenStream | ( | const String & | fieldName,
|  | const ReaderPtr & | reader
| ) |  |

virtual

Creates a TokenStream that is allowed to be re-used from the previous time that the same thread called this method. Callers that do not need to use more than one TokenStream at the same time from this analyzer should use this method for better performance.

Reimplemented from Lucene::Analyzer.

## ◆ shared_from_this()

boost::shared_ptr< PerFieldAnalyzerWrapper > Lucene::PerFieldAnalyzerWrapper::shared_from_this | ( |  | ) |

inline

## ◆ tokenStream()

virtual TokenStreamPtr Lucene::PerFieldAnalyzerWrapper::tokenStream | ( | const String & | fieldName,
|  | const ReaderPtr & | reader
| ) |  |

virtual

Creates a TokenStream which tokenizes all the text in the provided Reader. Must be able to handle null field name for backward compatibility.

Implements Lucene::Analyzer.

## ◆ toString()

virtual String Lucene::PerFieldAnalyzerWrapper::toString | ( |  | ) |

virtual

Returns a string representation of the object.

Reimplemented from Lucene::LuceneObject.

## Field Documentation

## ◆ analyzerMap

MapStringAnalyzer Lucene::PerFieldAnalyzerWrapper::analyzerMap

protected

## ◆ defaultAnalyzer

AnalyzerPtr Lucene::PerFieldAnalyzerWrapper::defaultAnalyzer

protected

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

- PerFieldAnalyzerWrapper.h

clucene.sourceforge.net