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


Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
Lucene::TopDocsCollector Class Reference

A base class for all collectors that return a TopDocs output. This collector allows easy extension by providing a single constructor which accepts a PriorityQueue as well as protected members for that priority queue and a counter of the number of total hits. More...

#include <TopDocsCollector.h>

+ Inheritance diagram for Lucene::TopDocsCollector:

Public Member Functions

 TopDocsCollector (const HitQueueBasePtr &pq)
 
virtual ~TopDocsCollector ()
 
virtual String getClassName ()
 
boost::shared_ptr< TopDocsCollectorshared_from_this ()
 
virtual int32_t getTotalHits ()
 The total number of documents that matched this query.
 
virtual TopDocsPtr topDocs ()
 Returns the top docs that were collected by this collector.
 
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.
 
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.
 
- Public Member Functions inherited from Lucene::Collector
virtual ~Collector ()
 
boost::shared_ptr< Collectorshared_from_this ()
 
virtual void setScorer (const 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.
 
virtual void collect (int32_t doc)=0
 Called once for every document matching a query, with the unbased document number.
 
virtual void setNextReader (const 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).
 
virtual bool acceptsDocsOutOfOrder ()=0
 Return true if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) to collect.
 
- 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 ()
 
- Static Public Member Functions inherited from Lucene::Collector
static String _getClassName ()
 

Protected Member Functions

virtual void populateResults (Collection< ScoreDocPtr > results, int32_t howMany)
 Populates the results array with the ScoreDoc instances. This can be overridden in case a different ScoreDoc type should be returned.
 
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.
 
- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 

Static Protected Member Functions

static TopDocsPtr EMPTY_TOPDOCS ()
 This is used in case topDocs() is called with illegal parameters, or there simply aren't (enough) results.
 

Protected Attributes

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.
 
int32_t totalHits
 The total number of documents that the collector encountered.
 
- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Detailed Description

A base class for all collectors that return a TopDocs output. This collector allows easy extension by providing a single constructor which accepts a PriorityQueue as well as protected members for that priority queue and a counter of the number of total hits.

Extending classes can override topDocs(int32_t, int32_t) and getTotalHits() in order to provide their own implementation.

Constructor & Destructor Documentation

◆ TopDocsCollector()

Lucene::TopDocsCollector::TopDocsCollector ( const HitQueueBasePtr pq)

◆ ~TopDocsCollector()

virtual Lucene::TopDocsCollector::~TopDocsCollector ( )
virtual

Member Function Documentation

◆ _getClassName()

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

◆ EMPTY_TOPDOCS()

static TopDocsPtr Lucene::TopDocsCollector::EMPTY_TOPDOCS ( )
staticprotected

This is used in case topDocs() is called with illegal parameters, or there simply aren't (enough) results.

◆ getClassName()

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

Reimplemented from Lucene::Collector.

Reimplemented in Lucene::TopFieldCollector, and Lucene::TopScoreDocCollector.

◆ getTotalHits()

virtual int32_t Lucene::TopDocsCollector::getTotalHits ( )
virtual

The total number of documents that matched this query.

◆ newTopDocs()

virtual TopDocsPtr Lucene::TopDocsCollector::newTopDocs ( Collection< ScoreDocPtr results,
int32_t  start 
)
protectedvirtual

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 in Lucene::TopFieldCollector, and Lucene::TopScoreDocCollector.

◆ populateResults()

virtual void Lucene::TopDocsCollector::populateResults ( Collection< ScoreDocPtr results,
int32_t  howMany 
)
protectedvirtual

Populates the results array with the ScoreDoc instances. This can be overridden in case a different ScoreDoc type should be returned.

Reimplemented in Lucene::TopFieldCollector.

◆ shared_from_this()

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

◆ topDocs() [1/3]

virtual TopDocsPtr Lucene::TopDocsCollector::topDocs ( )
virtual

Returns the top docs that were collected by this collector.

◆ topDocs() [2/3]

virtual TopDocsPtr Lucene::TopDocsCollector::topDocs ( int32_t  start)
virtual

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.

This method is convenient to call if the application always asks for the last results, starting from the last 'page'.

NOTE: you cannot call this method more than once for each search execution. If you need to call it more than once, passing each time a different start, you should call topDocs() and work with the returned TopDocs object, which will contain all the results this search execution collected.

◆ topDocs() [3/3]

virtual TopDocsPtr Lucene::TopDocsCollector::topDocs ( int32_t  start,
int32_t  howMany 
)
virtual

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.

This method is useful to call in case pagination of search results is allowed by the search application, as well as it attempts to optimize the memory used by allocating only as much as requested by howMany.

NOTE: you cannot call this method more than once for each search execution. If you need to call it more than once, passing each time a different range, you should call topDocs() and work with the returned TopDocs object, which will contain all the results this search execution collected.

Field Documentation

◆ pq

HitQueueBasePtr Lucene::TopDocsCollector::pq
protected

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.

◆ totalHits

int32_t Lucene::TopDocsCollector::totalHits
protected

The total number of documents that the collector encountered.


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

clucene.sourceforge.net