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 | Protected Member Functions | Static Protected Member Functions | Protected Attributes
Lucene::TopFieldCollector Class Reference

A Collector that sorts by SortField using FieldComparators. More...

`#include <TopFieldCollector.h>`

Inheritance diagram for Lucene::TopFieldCollector:

## Public Member Functions

| TopFieldCollector (HitQueueBasePtr pq, int32_t numHits, bool fillFields)
virtual | ~TopFieldCollector ()
virtual String | getClassName ()
boost::shared_ptr < TopFieldCollector > | shared_from_this ()
virtual void | add (int32_t slot, int32_t doc, double score)
virtual bool | acceptsDocsOutOfOrder ()
| Return true if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) to collect. More...
Public Member Functions inherited from Lucene::TopDocsCollector
| TopDocsCollector (HitQueueBasePtr pq)
virtual | ~TopDocsCollector ()
boost::shared_ptr < TopDocsCollector > | shared_from_this ()
virtual int32_t | getTotalHits ()
| The total number of documents that matched this query. More...
virtual TopDocsPtr | topDocs ()
| Returns the top docs that were collected by this collector. More...
virtual TopDocsPtr | topDocs (int32_t start)
| Returns the documents in the range [start .. pq.size()) that were collected by this collector. Note that if start >= pq.size(), an empty TopDocs is returned. More...
virtual TopDocsPtr | topDocs (int32_t start, int32_t howMany)
| Returns the documents in the rage [start .. start + howMany) that were collected by this collector. Note that if start >= pq.size(), an empty TopDocs is returned, and if pq.size() - start < howMany, then only the available documents in [start .. pq.size()) are returned. More...
Public Member Functions inherited from Lucene::Collector
virtual | ~Collector ()
boost::shared_ptr< Collector > | shared_from_this ()
virtual void | setScorer (ScorerPtr scorer)=0
| Called before successive calls to collect(int32_t). Implementations that need the score of the current document (passed-in to collect(int32_t)), should save the passed-in Scorer and call scorer.score() when needed. More...
virtual void | collect (int32_t doc)=0
| Called once for every document matching a query, with the unbased document number. More...
virtual void | setNextReader (IndexReaderPtr reader, int32_t docBase)=0
| Called before collecting from each IndexReader. All doc ids in collect(int32_t) will correspond to reader. Add docBase to the current IndexReaders internal document id to re-base ids in collect(int32_t). 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 ()
static TopFieldCollectorPtr | create (SortPtr sort, int32_t numHits, bool fillFields, bool trackDocScores, bool trackMaxScore, bool docsScoredInOrder)
| Creates a new TopFieldCollector from the given arguments. More...
Static Public Member Functions inherited from Lucene::TopDocsCollector
static String | _getClassName ()
Static Public Member Functions inherited from Lucene::Collector
static String | _getClassName ()

## Protected Member Functions

virtual void | populateResults (Collection< ScoreDocPtr > results, int32_t howMany)
| Only the following callback methods need to be overridden since topDocs(int32_t, int32_t) calls them to return the results. More...
virtual TopDocsPtr | newTopDocs (Collection< ScoreDocPtr > results, int32_t start)
| Returns a TopDocs instance containing the given results. If results is null it means there are no results to return, either because there were 0 calls to collect() or because the arguments to topDocs were invalid. More...

## Static Protected Member Functions

static const Collection < ScoreDocPtr > | EMPTY_SCOREDOCS ()
Static Protected Member Functions inherited from Lucene::TopDocsCollector
static TopDocsPtr | EMPTY_TOPDOCS ()
| This is used in case topDocs() is called with illegal parameters, or there simply aren't (enough) results. More...

## Protected Attributes

bool | fillFields
double | maxScore
| Stores the maximum score value encountered, needed for normalizing. If document scores are not tracked, this value is initialized to NaN. More...
int32_t | numHits
FieldValueHitQueueEntryPtr | bottom
bool | queueFull
int32_t | docBase
Protected Attributes inherited from Lucene::TopDocsCollector
HitQueueBasePtr | pq
| The priority queue which holds the top documents. Note that different implementations of PriorityQueue give different meaning to 'top documents'. HitQueue for example aggregates the top scoring documents, while other PQ implementations may hold documents sorted by other criteria. More...
int32_t | totalHits
| The total number of documents that the collector encountered. More...

## Detailed Description

A Collector that sorts by SortField using FieldComparators.

See the create(SortPtr, int32_t, bool, bool, bool, bool) method for instantiating a TopFieldCollector.

## Constructor & Destructor Documentation

Lucene::TopFieldCollector::TopFieldCollector | ( | HitQueueBasePtr | pq,
|  | int32_t | numHits,
|  | bool | fillFields
| ) |  |

virtual Lucene::TopFieldCollector::~TopFieldCollector | ( | ) |  |

virtual

## Member Function Documentation

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

inline static

virtual bool Lucene::TopFieldCollector::acceptsDocsOutOfOrder | ( | ) |  |

virtual

Return true if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) to collect.

Most Lucene Query implementations will visit matching docIDs in order. However, some queries (currently limited to certain cases of BooleanQuery) can achieve faster searching if the Collector allows them to deliver the docIDs out of order.

Many collectors don't mind getting docIDs out of order, so it's important to return true here.

Implements Lucene::Collector.

virtual void Lucene::TopFieldCollector::add | ( | int32_t | slot,
|  | int32_t | doc,
|  | double | score
| ) |  |

virtual

static TopFieldCollectorPtr Lucene::TopFieldCollector::create | ( | SortPtr | sort,
|  | int32_t | numHits,
|  | bool | fillFields,
|  | bool | trackDocScores,
|  | bool | trackMaxScore,
|  | bool | docsScoredInOrder
| ) |  |

static

Creates a new TopFieldCollector from the given arguments.

NOTE: The instances returned by this method pre-allocate a full array of length numHits.

Parameters

  sort | The sort criteria (SortFields).
  numHits | The number of results to collect.
  fillFields | Specifies whether the actual field values should be returned on the results (FieldDoc).
  trackDocScores | Specifies whether document scores should be tracked and set on the results. Note that if set to false, then the results' scores will be set to NaN. Setting this to true affects performance, as it incurs the score computation on each competitive result. Therefore if document scores are not required by the application, it is recommended to set it to false.
  trackMaxScore | Specifies whether the query's maxScore should be tracked and set on the resulting TopDocs. Note that if set to false, TopDocs#getMaxScore() returns NaN. Setting this to true affects performance as it incurs the score computation on each result. Also, setting this true automatically sets trackDocScores to true as well.
  docsScoredInOrder | Specifies whether documents are scored in doc Id order or not by the given Scorer in setScorer(ScorerPtr).

Returns
  a TopFieldCollector instance which will sort the results by the sort criteria.

static const Collection<ScoreDocPtr> Lucene::TopFieldCollector::EMPTY_SCOREDOCS | ( | ) |  |

static protected

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

inline virtual

Reimplemented from Lucene::TopDocsCollector.

virtual TopDocsPtr Lucene::TopFieldCollector::newTopDocs | ( | Collection< ScoreDocPtr > | results,
|  | int32_t | start
| ) |  |

protected virtual

Returns a TopDocs instance containing the given results. If results is null it means there are no results to return, either because there were 0 calls to collect() or because the arguments to topDocs were invalid.

Reimplemented from Lucene::TopDocsCollector.

virtual void Lucene::TopFieldCollector::populateResults | ( | Collection< ScoreDocPtr > | results,
|  | int32_t | howMany
| ) |  |

protected virtual

Only the following callback methods need to be overridden since topDocs(int32_t, int32_t) calls them to return the results.

Reimplemented from Lucene::TopDocsCollector.

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

inline

## Field Documentation

FieldValueHitQueueEntryPtr Lucene::TopFieldCollector::bottom

protected

int32_t Lucene::TopFieldCollector::docBase

protected

bool Lucene::TopFieldCollector::fillFields

protected

double Lucene::TopFieldCollector::maxScore

protected

Stores the maximum score value encountered, needed for normalizing. If document scores are not tracked, this value is initialized to NaN.

int32_t Lucene::TopFieldCollector::numHits

protected

bool Lucene::TopFieldCollector::queueFull

protected

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

- TopFieldCollector.h

clucene.sourceforge.net