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


Loading...
Searching...
No Matches
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.
 
virtual ~CustomScoreProvider ()
 
virtual String getClassName ()
 
boost::shared_ptr< CustomScoreProvidershared_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.
 
virtual double customScore (int32_t doc, double subQueryScore, double valSrcScore)
 Compute a custom score by the subQuery score and the ValueSourceQuery score.
 
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.
 
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.
 
- 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.
 
virtual String toString ()
 Returns a string representation of the object.
 
- 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 ()
 

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

◆ CustomScoreProvider()

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

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

◆ ~CustomScoreProvider()

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

Member Function Documentation

◆ _getClassName()

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

◆ customExplain() [1/2]

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
docdoc being explained.
subQueryExplexplanation for the sub-query part.
valSrcExplsexplanation for the value source part.
Returns
an explanation for the custom score

◆ customExplain() [2/2]

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
docdoc being explained.
subQueryExplexplanation for the sub-query part.
valSrcExplexplanation for the value source part.
Returns
an explanation for the custom score

◆ customScore() [1/2]

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
docid of scored doc.
subQueryScorescore of that doc by the subQuery.
valSrcScoresscores of that doc by the ValueSourceQuery.
Returns
custom score.

◆ customScore() [2/2]

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
docid of scored doc.
subQueryScorescore of that doc by the subQuery.
valSrcScorescore of that doc by the ValueSourceQuery.
Returns
custom score.

◆ getClassName()

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

◆ shared_from_this()

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

Field Documentation

◆ reader

IndexReaderPtr Lucene::CustomScoreProvider::reader
protected

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

clucene.sourceforge.net