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

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

- Data Structures
- Class Hierarchy
- Data Fields

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions
Lucene::Weight Class Referenceabstract

Calculate query weights and build query scorers. More...

`#include <Weight.h>`

Inheritance diagram for Lucene::Weight:

## Public Member Functions

virtual | ~Weight ()
virtual String | getClassName ()
boost::shared_ptr< Weight > | shared_from_this ()
virtual ExplanationPtr | explain (IndexReaderPtr reader, int32_t doc)=0
| An explanation of the score computation for the named document. More...
virtual QueryPtr | getQuery ()=0
| The query that this concerns. More...
virtual double | getValue ()=0
| The weight for this query. More...
virtual void | normalize (double norm)=0
| Assigns the query normalization factor to this. More...
virtual ScorerPtr | scorer (IndexReaderPtr reader, bool scoreDocsInOrder, bool topScorer)=0
| Returns a Scorer which scores documents in/out-of order according to scoreDocsInOrder. More...
virtual double | sumOfSquaredWeights ()=0
| The sum of squared weights of contained query clauses. More...
virtual bool | scoresDocsOutOfOrder ()
| Returns true if this implementation scores docs only out of order. This method is used in conjunction with Collector's acceptsDocsOutOfOrder and scorer(IndexReaderPtr, bool, bool) to create a matching Scorer instance for a given Collector, or vice versa. 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 (LuceneObjectPtr other=LuceneObjectPtr())
| Return clone of this object. More...
virtual int32_t | hashCode ()
| Return hash code for this object. More...
virtual bool | equals (LuceneObjectPtr other)
| Return whether two objects are equal. More...
virtual int32_t | compareTo (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 ()

## Additional Inherited Members

Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Detailed Description

Calculate query weights and build query scorers.

The purpose of Weight is to ensure searching does not modify a Query, so that a Query instance can be reused. Searcher dependent state of the query should reside in the Weight. IndexReader dependent state should reside in the Scorer.

Weight is used in the following way:

1. A Weight is constructed by a top-level query, given a Searcher (Query#createWeight(Searcher)).
2. The sumOfSquaredWeights() method is called on the Weight to compute the query normalization factor Similarity#queryNorm(float) of the query clauses contained in the query.
3. The query normalization factor is passed to normalize(float). At this point the weighting is complete.
4. A Scorer is constructed by scorer(IndexReaderPtr, bool, bool).

## Constructor & Destructor Documentation

virtual Lucene::Weight::~Weight | ( | ) |  |

virtual

## Member Function Documentation

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

inline static

virtual ExplanationPtr Lucene::Weight::explain | ( | IndexReaderPtr | reader,
|  | int32_t | doc
| ) |  |

pure virtual

An explanation of the score computation for the named document.

Parameters

  reader | sub-reader containing the give doc
  doc |

Returns
  an Explanation for the score

Implemented in Lucene::SpanWeight.

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

inline virtual

Reimplemented in Lucene::PayloadNearSpanWeight, and Lucene::SpanWeight.

virtual QueryPtr Lucene::Weight::getQuery | ( | ) |  |

pure virtual

The query that this concerns.

Implemented in Lucene::SpanWeight.

virtual double Lucene::Weight::getValue | ( | ) |  |

pure virtual

The weight for this query.

Implemented in Lucene::SpanWeight.

virtual void Lucene::Weight::normalize | ( | double | norm) |  |

pure virtual

Assigns the query normalization factor to this.

Implemented in Lucene::SpanWeight.

virtual ScorerPtr Lucene::Weight::scorer | ( | IndexReaderPtr | reader,
|  | bool | scoreDocsInOrder,
|  | bool | topScorer
| ) |  |

pure virtual

Returns a Scorer which scores documents in/out-of order according to scoreDocsInOrder.

NOTE: even if scoreDocsInOrder is false, it is recommended to check whether the returned Scorer indeed scores documents out of order (ie., call scoresDocsOutOfOrder()), as some Scorer implementations will always return documents in-order.

NOTE: null can be returned if no documents will be scored by this query.

Parameters

  reader | The IndexReader for which to return the Scorer.

  scoreDocsInOrder

  Specifies whether in-order scoring of documents is required. Note that if set to false (i.e., out-of-order scoring is required), this method can return whatever scoring mode it supports, as every in-order scorer is also an out-of-order one. However, an out-of-order scorer may not support Scorer#nextDoc() and/or Scorer#advance(int), therefore it is recommended to request an in-order scorer if use of these methods is required.

  topScorer | If true, Scorer#score(CollectorPtr) will be called; if false, Scorer#nextDoc() and/or Scorer#advance(int) will be called.

Returns
  a Scorer which scores documents in/out-of order.

Implemented in Lucene::PayloadNearSpanWeight, and Lucene::SpanWeight.

virtual bool Lucene::Weight::scoresDocsOutOfOrder | ( | ) |  |

virtual

Returns true if this implementation scores docs only out of order. This method is used in conjunction with Collector's acceptsDocsOutOfOrder and scorer(IndexReaderPtr, bool, bool) to create a matching Scorer instance for a given Collector, or vice versa.

NOTE: the default implementation returns false, ie. the Scorer scores documents in-order.

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

inline

virtual double Lucene::Weight::sumOfSquaredWeights | ( | ) |  |

pure virtual

The sum of squared weights of contained query clauses.

Implemented in Lucene::SpanWeight.

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

- Weight.h

clucene.sourceforge.net