# Xapian::Weight Class Reference

Abstract base class for weighting schemes. More...

Inheritance diagram for Xapian::Weight:

[legend]

List of all members.

## Public Member Functions
Weight * | create (const Internal *internal_, Xapian::doclength querysize_, Xapian::termcount wqf_, const std::string &tname_) const
| Create a new weight object of the same type as this and initialise it with the specified statistics.
virtual std::string | name () const =0
| Name of the weighting scheme.
virtual std::string | serialise () const =0
| Serialise object parameters into a string.
virtual Weight * | unserialise (const std::string &s) const =0
| Create object given string serialisation returned by serialise().
virtual Xapian::weight | get_sumpart (Xapian::termcount wdf, Xapian::doclength len) const =0
| Get a weight which is part of the sum over terms being performed.
virtual Xapian::weight | get_maxpart () const =0
| Gets the maximum value that get_sumpart() may return.
virtual Xapian::weight | get_sumextra (Xapian::doclength len) const =0
| Get an extra weight for a document to add to the sum calculated over the query terms.
virtual Xapian::weight | get_maxextra () const =0
| Gets the maximum value that get_sumextra() may return.
virtual bool | get_sumpart_needs_doclength () const
| return false if the weight object doesn't need doclength
## Protected Member Functions
| Weight (const Weight &)
## Protected Attributes
const Internal * | internal
Xapian::doclength | querysize
Xapian::termcount | wqf
std::string | tname

## Detailed Description

Abstract base class for weighting schemes.

## Member Function Documentation

Weight* Xapian::Weight::create | ( | const Internal * | internal_,
|  | Xapian::doclength | querysize_,
|  | Xapian::termcount | wqf_,
|  | const std::string & | tname_ |
| ) |  |  | const

Create a new weight object of the same type as this and initialise it with the specified statistics.

You shouldn't call this method yourself - it's called by Enquire.

Parameters:

  | internal_ | Object to ask for collection statistics.
  | querysize_ | Query size.
  | wqf_ | Within query frequency of term this object is associated with.
  | tname_ | Term which this object is associated with.

virtual Xapian::weight Xapian::Weight::get_maxextra | ( |  | ) | const`[pure virtual]`

Gets the maximum value that get_sumextra() may return.

This is used in optimising searches.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, and Xapian::TradWeight.

virtual Xapian::weight Xapian::Weight::get_maxpart | ( |  | ) | const`[pure virtual]`

Gets the maximum value that get_sumpart() may return.

This is used in optimising searches, by having the postlist tree decay appropriately when parts of it can have limited, or no, further effect.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, and Xapian::TradWeight.

virtual Xapian::weight Xapian::Weight::get_sumextra | ( | Xapian::doclength | len | ) | const`[pure virtual]`

Get an extra weight for a document to add to the sum calculated over the query terms.

This returns a weight for a given document, and is used by some weighting schemes to account for influence such as document length.

Parameters:

  | len | the (unnormalised) document length.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, and Xapian::TradWeight.

virtual Xapian::weight Xapian::Weight::get_sumpart | ( | Xapian::termcount | wdf,
|  | Xapian::doclength | len |
| ) |  |  | const`[pure virtual]`

Get a weight which is part of the sum over terms being performed.

This returns a weight for a given term and document. These weights are summed to give a total weight for the document.

Parameters:

  | wdf | the within document frequency of the term.
  | len | the (unnormalised) document length.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, and Xapian::TradWeight.

virtual bool Xapian::Weight::get_sumpart_needs_doclength | ( |  | ) | const`[virtual]`

return false if the weight object doesn't need doclength

Reimplemented in Xapian::BoolWeight, Xapian::BM25Weight, and Xapian::TradWeight.

virtual std::string Xapian::Weight::name | ( |  | ) | const`[pure virtual]`

Name of the weighting scheme.

If the subclass is called FooWeight, this should return "Foo".

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, and Xapian::TradWeight.

virtual std::string Xapian::Weight::serialise | ( |  | ) | const`[pure virtual]`

Serialise object parameters into a string.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, and Xapian::TradWeight.

virtual Weight* Xapian::Weight::unserialise | ( | const std::string & | s | ) | const`[pure virtual]`

Create object given string serialisation returned by serialise().

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, and Xapian::TradWeight.

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

- xapian/enquire.h