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

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Static Public Member Functions | Protected Attributes
Lucene::CustomScoreProvider Class Reference

An instance of this subclass should be returned by CustomScoreQuery#getCustomScoreProvider, if you want to modify the custom score calculation of a CustomScoreQuery. More...

`#include <CustomScoreProvider.h>`

Inheritance diagram for Lucene::CustomScoreProvider:

## Public Member Functions

| CustomScoreProvider (const IndexReaderPtr &reader)
| Creates a new instance of the provider class for the given IndexReader. More...
virtual | ~CustomScoreProvider ()
virtual String | getClassName ()
boost::shared_ptr< CustomScoreProvider > | shared_from_this ()
virtual double | customScore (int32_t doc, double subQueryScore, Collection< double > valSrcScores)
| Compute a custom score by the subQuery score and a number of ValueSourceQuery scores. More...
virtual double | customScore (int32_t doc, double subQueryScore, double valSrcScore)
| Compute a custom score by the subQuery score and the ValueSourceQuery score. More...
virtual ExplanationPtr | customExplain (int32_t doc, const ExplanationPtr &subQueryExpl, Collection< ExplanationPtr > valSrcExpls)
| Explain the custom score. Whenever overriding customScore(int32_t, double, Collection<double>), this method should also be overridden to provide the correct explanation for the part of the custom scoring. More...
virtual ExplanationPtr | customExplain (int32_t doc, const ExplanationPtr &subQueryExpl, const ExplanationPtr &valSrcExpl)
| Explain the custom score. Whenever overriding customScore(int32_t, double, double), this method should also be overridden to provide the correct explanation for the part of the custom scoring. More...
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. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object. More...
virtual int32_t | hashCode ()
| Return hash code for this object. More...
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal. More...
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects. More...
virtual String | toString ()
| Returns a string representation of the object. More...
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock. More...
virtual LuceneSignalPtr | getSignal ()
| Return this object signal. More...
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout. More...
virtual void | unlock ()
| Unlock this object. More...
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread. More...
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout. More...
virtual void | notifyAll ()
| Notify all threads waiting for signal. More...

## Static Public Member Functions

static String | _getClassName ()

## Protected Attributes

IndexReaderPtr | reader
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Additional Inherited Members

Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## Detailed Description

An instance of this subclass should be returned by CustomScoreQuery#getCustomScoreProvider, if you want to modify the custom score calculation of a CustomScoreQuery.

Since Lucene 2.9, queries operate on each segment of an Index separately, so overriding the similar (now deprecated) methods in CustomScoreQuery is no longer suitable, as the supplied doc ID is per-segment and without knowledge of the IndexReader you cannot access the document or FieldCache.

## Constructor & Destructor Documentation

Lucene::CustomScoreProvider::CustomScoreProvider | ( | const IndexReaderPtr & | reader | ) |

Creates a new instance of the provider class for the given IndexReader.

virtual Lucene::CustomScoreProvider::~CustomScoreProvider | ( |  | ) |

virtual

## Member Function Documentation

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

inline static

virtual ExplanationPtr Lucene::CustomScoreProvider::customExplain | ( | int32_t | doc,
|  | const ExplanationPtr & | subQueryExpl,
|  | Collection< ExplanationPtr > | valSrcExpls
| ) |  |

virtual

Explain the custom score. Whenever overriding customScore(int32_t, double, Collection<double>), this method should also be overridden to provide the correct explanation for the part of the custom scoring.

Parameters

  doc | doc being explained.
  subQueryExpl | explanation for the sub-query part.
  valSrcExpls | explanation for the value source part.

Returns
  an explanation for the custom score

virtual ExplanationPtr Lucene::CustomScoreProvider::customExplain | ( | int32_t | doc,
|  | const ExplanationPtr & | subQueryExpl,
|  | const ExplanationPtr & | valSrcExpl
| ) |  |

virtual

Explain the custom score. Whenever overriding customScore(int32_t, double, double), this method should also be overridden to provide the correct explanation for the part of the custom scoring.

Parameters

  doc | doc being explained.
  subQueryExpl | explanation for the sub-query part.
  valSrcExpl | explanation for the value source part.

Returns
  an explanation for the custom score

virtual double Lucene::CustomScoreProvider::customScore | ( | int32_t | doc,
|  | double | subQueryScore,
|  | Collection< double > | valSrcScores
| ) |  |

virtual

Compute a custom score by the subQuery score and a number of ValueSourceQuery scores.

Subclasses can override this method to modify the custom score.

If your custom scoring is different than the default herein you should override at least one of the two customScore() methods. If the number of ValueSourceQueries is always < 2 it is sufficient to override the other customScore() method, which is simpler.

The default computation herein is a multiplication of given scores:

    ModifiedScore = valSrcScore * valSrcScores[0] * valSrcScores[1] * ...

Parameters

  doc | id of scored doc.
  subQueryScore | score of that doc by the subQuery.
  valSrcScores | scores of that doc by the ValueSourceQuery.

Returns
  custom score.

virtual double Lucene::CustomScoreProvider::customScore | ( | int32_t | doc,
|  | double | subQueryScore,
|  | double | valSrcScore
| ) |  |

virtual

Compute a custom score by the subQuery score and the ValueSourceQuery score.

Subclasses can override this method to modify the custom score.

If your custom scoring is different than the default herein you should override at least one of the two customScore() methods. If the number of ValueSourceQueries is always < 2 it is sufficient to override this customScore() method, which is simpler.

The default computation herein is a multiplication of the two scores:

    ModifiedScore = subQueryScore * valSrcScore

Parameters

  doc | id of scored doc.
  subQueryScore | score of that doc by the subQuery.
  valSrcScore | score of that doc by the ValueSourceQuery.

Returns
  custom score.

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

inline virtual

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

inline

## Field Documentation

IndexReaderPtr Lucene::CustomScoreProvider::reader

protected

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

- CustomScoreProvider.h

clucene.sourceforge.net