Lucene++ - a full-featured, c++ search engine
API Documentation
A Collector
implementation that collects the top-scoring hits, returning them as a TopDocs
. This is used by IndexSearcher
to implement TopDocs
-based search. Hits are sorted by score descending and then (when the scores are tied) docID ascending. When you create an instance of this collector you should know in advance whether documents are going to be collected in doc Id order or not.
More...
#include <TopScoreDocCollector.h>
Public Member Functions | |
TopScoreDocCollector (int32_t numHits) | |
virtual | ~TopScoreDocCollector () |
virtual String | getClassName () |
boost::shared_ptr< TopScoreDocCollector > | shared_from_this () |
virtual void | setNextReader (const IndexReaderPtr &reader, int32_t docBase) |
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 void | setScorer (const ScorerPtr &scorer) |
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. | |
![]() | |
TopDocsCollector (const HitQueueBasePtr &pq) | |
virtual | ~TopDocsCollector () |
boost::shared_ptr< TopDocsCollector > | shared_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. | |
![]() | |
virtual | ~Collector () |
boost::shared_ptr< Collector > | shared_from_this () |
virtual void | collect (int32_t doc)=0 |
Called once for every document matching a query, with the unbased document number. | |
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 . | |
![]() | |
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. | |
![]() | |
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 TopScoreDocCollectorPtr | create (int32_t numHits, bool docsScoredInOrder) |
Creates a new TopScoreDocCollector given the number of hits to collect and whether documents are scored in order by the input Scorer to setScorer(ScorerPtr) . | |
![]() | |
static String | _getClassName () |
![]() | |
static String | _getClassName () |
Data Fields | |
INTERNAL | : ScoreDocPtr pqTop |
int32_t | docBase |
ScorerWeakPtr | _scorer |
Scorer * | __scorer |
Protected Member Functions | |
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. | |
![]() | |
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. | |
![]() | |
LuceneObject () | |
Additional Inherited Members | |
![]() | |
static TopDocsPtr | EMPTY_TOPDOCS () |
This is used in case topDocs() is called with illegal parameters, or there simply aren't (enough) results. | |
![]() | |
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. | |
![]() | |
SynchronizePtr | objectLock |
LuceneSignalPtr | objectSignal |
A Collector
implementation that collects the top-scoring hits, returning them as a TopDocs
. This is used by IndexSearcher
to implement TopDocs
-based search. Hits are sorted by score descending and then (when the scores are tied) docID ascending. When you create an instance of this collector you should know in advance whether documents are going to be collected in doc Id order or not.
NOTE: The values Nan, NEGATIVE_INFINITY and POSITIVE_INFINITY are not valid scores. This collector will not properly collect hits with such scores.
Lucene::TopScoreDocCollector::TopScoreDocCollector | ( | int32_t | numHits | ) |
|
virtual |
|
inlinestatic |
|
static |
Creates a new TopScoreDocCollector
given the number of hits to collect and whether documents are scored in order by the input Scorer
to setScorer(ScorerPtr)
.
NOTE: The instances returned by this method pre-allocate a full array of length numHits.
|
inlinevirtual |
Reimplemented from Lucene::TopDocsCollector.
|
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 from Lucene::TopDocsCollector.
|
virtual |
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)
.
reader | next IndexReader |
docBase |
Implements Lucene::Collector.
|
virtual |
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.
Implements Lucene::Collector.
|
inline |
INTERNAL Lucene::TopScoreDocCollector::__pad0__ |
Scorer* Lucene::TopScoreDocCollector::__scorer |
ScorerWeakPtr Lucene::TopScoreDocCollector::_scorer |
int32_t Lucene::TopScoreDocCollector::docBase |