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

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

Default scoring implementation. More...

`#include <DefaultSimilarity.h>`

Inheritance diagram for Lucene::DefaultSimilarity:

## Public Member Functions

| DefaultSimilarity ()
virtual | ~DefaultSimilarity ()
virtual String | getClassName ()
boost::shared_ptr< DefaultSimilarity > | shared_from_this ()
virtual double | computeNorm (const String &fieldName, const FieldInvertStatePtr &state)
| Implemented as state->getBoost() * lengthNorm(numTerms), where numTerms is {} if #setDiscountOverlaps} is false, else it's { FieldInvertState#getLength()} - FieldInvertState#getNumOverlap()}. More...
virtual double | lengthNorm (const String &fieldName, int32_t numTokens)
| Implemented as 1 / sqrt(numTerms). More...
virtual double | queryNorm (double sumOfSquaredWeights)
| Implemented as 1 / sqrt(sumOfSquaredWeights). More...
virtual double | tf (double freq)
| Implemented as sqrt(freq). More...
virtual double | sloppyFreq (int32_t distance)
| Implemented as 1 / (distance + 1). More...
virtual double | idf (int32_t docFreq, int32_t numDocs)
| Implemented as log(numDocs / (docFreq + 1)) + 1. More...
virtual double | coord (int32_t overlap, int32_t maxOverlap)
| Implemented as overlap / maxOverlap. More...
void | setDiscountOverlaps (bool v)
| Determines whether overlap tokens (Tokens with 0 position increment) are ignored when computing norm. By default this is false, meaning overlap tokens are counted just like non-overlap tokens. More...
bool | getDiscountOverlaps ()
Public Member Functions inherited from Lucene::Similarity
| Similarity ()
virtual | ~Similarity ()
boost::shared_ptr< Similarity > | shared_from_this ()
virtual double | tf (int32_t freq)
| Computes a score factor based on a term or phrase's frequency in a document. This value is multiplied by the idf(int32_t, int32_t) factor for each term in the query and these products are then summed to form the initial score for a document. More...
virtual IDFExplanationPtr | idfExplain (const TermPtr &term, const SearcherPtr &searcher)
| Computes a score factor for a simple term and returns an explanation for that score factor. More...
virtual IDFExplanationPtr | idfExplain (Collection< TermPtr > terms, const SearcherPtr &searcher)
| Computes a score factor for a phrase. More...
virtual double | scorePayload (int32_t docId, const String &fieldName, int32_t start, int32_t end, ByteArray payload, int32_t offset, int32_t length)
| Calculate a scoring factor based on the data in the payload. Overriding implementations are responsible for interpreting what is in the payload. Lucene makes no assumptions about what is in the byte array. 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 ()
Static Public Member Functions inherited from Lucene::Similarity
static String | _getClassName ()
static SimilarityPtr | getDefault ()
| Return the default Similarity implementation used by indexing and search code. This is initially an instance of DefaultSimilarity. More...
static double | decodeNorm (uint8_t b)
| Decodes a normalization factor stored in an index. More...
static const Collection< double > | getNormDecoder ()
| Returns a table for decoding normalization bytes. More...
static uint8_t | encodeNorm (double f)
| Encodes a normalization factor for storage in an index. More...

## Protected Attributes

bool | discountOverlaps
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Additional Inherited Members

Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()
Static Protected Member Functions inherited from Lucene::Similarity
static const Collection< double > | NORM_TABLE ()
Static Protected Attributes inherited from Lucene::Similarity
static const int32_t | NO_DOC_ID_PROVIDED

## Detailed Description

Default scoring implementation.

## Constructor & Destructor Documentation

## ◆ DefaultSimilarity()

Lucene::DefaultSimilarity::DefaultSimilarity | ( |  | ) |

## ◆ ~DefaultSimilarity()

virtual Lucene::DefaultSimilarity::~DefaultSimilarity | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

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

inline static

## ◆ computeNorm()

virtual double Lucene::DefaultSimilarity::computeNorm | ( | const String & | fieldName,
|  | const FieldInvertStatePtr & | state
| ) |  |

virtual

Implemented as state->getBoost() * lengthNorm(numTerms), where numTerms is {} if #setDiscountOverlaps} is false, else it's { FieldInvertState#getLength()} - FieldInvertState#getNumOverlap()}.

Reimplemented from Lucene::Similarity.

## ◆ coord()

virtual double Lucene::DefaultSimilarity::coord | ( | int32_t | overlap,
|  | int32_t | maxOverlap
| ) |  |

virtual

Implemented as overlap / maxOverlap.

Implements Lucene::Similarity.

## ◆ getClassName()

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

inline virtual

Reimplemented from Lucene::Similarity.

## ◆ getDiscountOverlaps()

bool Lucene::DefaultSimilarity::getDiscountOverlaps | ( |  | ) |

See also
  setDiscountOverlaps

## ◆ idf()

virtual double Lucene::DefaultSimilarity::idf | ( | int32_t | docFreq,
|  | int32_t | numDocs
| ) |  |

virtual

Implemented as log(numDocs / (docFreq + 1)) + 1.

Implements Lucene::Similarity.

## ◆ lengthNorm()

virtual double Lucene::DefaultSimilarity::lengthNorm | ( | const String & | fieldName,
|  | int32_t | numTokens
| ) |  |

virtual

Implemented as 1 / sqrt(numTerms).

Implements Lucene::Similarity.

## ◆ queryNorm()

virtual double Lucene::DefaultSimilarity::queryNorm | ( | double | sumOfSquaredWeights | ) |

virtual

Implemented as 1 / sqrt(sumOfSquaredWeights).

Implements Lucene::Similarity.

## ◆ setDiscountOverlaps()

void Lucene::DefaultSimilarity::setDiscountOverlaps | ( | bool | v | ) |

Determines whether overlap tokens (Tokens with 0 position increment) are ignored when computing norm. By default this is false, meaning overlap tokens are counted just like non-overlap tokens.

See also
  computeNorm

## ◆ shared_from_this()

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

inline

## ◆ sloppyFreq()

virtual double Lucene::DefaultSimilarity::sloppyFreq | ( | int32_t | distance | ) |

virtual

Implemented as 1 / (distance + 1).

Implements Lucene::Similarity.

## ◆ tf()

virtual double Lucene::DefaultSimilarity::tf | ( | double | freq | ) |

virtual

Implemented as sqrt(freq).

Implements Lucene::Similarity.

## Field Documentation

## ◆ discountOverlaps

bool Lucene::DefaultSimilarity::discountOverlaps

protected

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

- DefaultSimilarity.h

clucene.sourceforge.net