java.lang.Object
org.apache.lucene.search.TopDocsCollector<FieldValueHitQueue.Entry>
org.apache.lucene.search.TopFieldCollector
- All Implemented Interfaces:
Collector
- Direct Known Subclasses:
TopFieldCollector.PagingFieldCollector,TopFieldCollector.SimpleFieldCollector
A
Collector that sorts by SortField using FieldComparators.
See the create(org.apache.lucene.search.Sort, int, int) method for instantiating a
TopFieldCollector.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class(package private) static classprivate class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) FieldValueHitQueue.Entry(package private) final boolean(package private) intprivate static final ScoreDoc[](package private) final FieldComparator<?> (package private) final HitsThresholdChecker(package private) float(package private) final MaxScoreAccumulator(package private) final boolean(package private) final int(package private) final int(package private) boolean(package private) final ScoreMode(package private) BooleanFields inherited from class org.apache.lucene.search.TopDocsCollector
EMPTY_TOPDOCS, pq, totalHits, totalHitsRelation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTopFieldCollector(FieldValueHitQueue<FieldValueHitQueue.Entry> pq, int numHits, HitsThresholdChecker hitsThresholdChecker, boolean needsScores, MaxScoreAccumulator minScoreAcc) -
Method Summary
Modifier and TypeMethodDescription(package private) final voidadd(int slot, int doc) (package private) static booleancanEarlyTerminate(Sort searchSort, Sort indexSort) private static booleancanEarlyTerminateOnDocId(Sort searchSort) private static booleancanEarlyTerminateOnPrefix(Sort searchSort, Sort indexSort) static TopFieldCollectorDeprecated.static TopFieldCollectorDeprecated.This method is deprecated in favor of the constructor ofTopFieldCollectorManagerdue to its support for concurrency in IndexSearchercreateSharedManager(Sort sort, int numHits, FieldDoc after, int totalHitsThreshold) Deprecated.This method is deprecated in favor of the constructor ofTopFieldCollectorManagerdue to its support for concurrency in IndexSearcherbooleanReturn whether collection terminated early.protected TopDocsnewTopDocs(ScoreDoc[] results, int start) Returns aTopDocsinstance containing the given results.protected voidpopulateResults(ScoreDoc[] results, int howMany) Populates the results array with the ScoreDoc instances.static voidpopulateScores(ScoreDoc[] topDocs, IndexSearcher searcher, Query query) Populatescoresof the giventopDocs.Indicates what features are required from the scorer.topDocs()Returns the top docs that were collected by this collector.(package private) final voidupdateBottom(int doc) protected voidprotected voidupdateMinCompetitiveScore(Scorable scorer) Methods inherited from class org.apache.lucene.search.TopDocsCollector
getTotalHits, topDocs, topDocs, topDocsSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.search.Collector
getLeafCollector, setWeight
-
Field Details
-
EMPTY_SCOREDOCS
-
numHits
final int numHits -
hitsThresholdChecker
-
firstComparator
-
canSetMinScore
final boolean canSetMinScore -
searchSortPartOfIndexSort
Boolean searchSortPartOfIndexSort -
minScoreAcc
-
minCompetitiveScore
float minCompetitiveScore -
numComparators
final int numComparators -
bottom
FieldValueHitQueue.Entry bottom -
queueFull
boolean queueFull -
docBase
int docBase -
needsScores
final boolean needsScores -
scoreMode
-
-
Constructor Details
-
TopFieldCollector
private TopFieldCollector(FieldValueHitQueue<FieldValueHitQueue.Entry> pq, int numHits, HitsThresholdChecker hitsThresholdChecker, boolean needsScores, MaxScoreAccumulator minScoreAcc)
-
-
Method Details
-
canEarlyTerminate
-
canEarlyTerminateOnDocId
-
canEarlyTerminateOnPrefix
-
scoreMode
Description copied from interface:CollectorIndicates what features are required from the scorer. -
updateGlobalMinCompetitiveScore
- Throws:
IOException
-
updateMinCompetitiveScore
- Throws:
IOException
-
create
Deprecated.This method is deprecated in favor of the constructor ofTopFieldCollectorManagerdue to its support for concurrency in IndexSearcherCreates a newTopFieldCollectorfrom 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.totalHitsThreshold- the number of docs to count accurately. If the query matches more thantotalHitsThresholdhits then its hit count will be a lower bound. On the other hand if the query matches less than or exactlytotalHitsThresholdhits then the hit count of the result will be accurate.Integer.MAX_VALUEmay be used to make the hit count accurate, but this will also make query processing slower.- Returns:
- a
TopFieldCollectorinstance which will sort the results by the sort criteria.
-
create
@Deprecated public static TopFieldCollector create(Sort sort, int numHits, FieldDoc after, int totalHitsThreshold) Deprecated.This method is deprecated in favor of the constructor ofTopFieldCollectorManagerdue to its support for concurrency in IndexSearcherCreates a newTopFieldCollectorfrom 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.after- only hits after this FieldDoc will be collectedtotalHitsThreshold- the number of docs to count accurately. If the query matches more thantotalHitsThresholdhits then its hit count will be a lower bound. On the other hand if the query matches less than or exactlytotalHitsThresholdhits then the hit count of the result will be accurate.Integer.MAX_VALUEmay be used to make the hit count accurate, but this will also make query processing slower. Setting totalHitsThreshold less thanInteger.MAX_VALUEinstructs Lucene to skip non-competitive documents whenever possible. For numeric sort fields the skipping functionality works when the same field is indexed both with doc values and points. In this case, there is an assumption that the same data is stored in these points and doc values.- Returns:
- a
TopFieldCollectorinstance which will sort the results by the sort criteria.
-
populateScores
public static void populateScores(ScoreDoc[] topDocs, IndexSearcher searcher, Query query) throws IOException Populatescoresof the giventopDocs.- Parameters:
topDocs- the top docs to populatesearcher- the index searcher that has been used to computetopDocsquery- the query that has been used to computetopDocs- Throws:
IllegalArgumentException- if there is evidence thattopDocshave been computed against a different searcher or a different query.IOException
-
add
final void add(int slot, int doc) -
updateBottom
final void updateBottom(int doc) -
populateResults
Description copied from class:TopDocsCollectorPopulates the results array with the ScoreDoc instances. This can be overridden in case a different ScoreDoc type should be returned.- Overrides:
populateResultsin classTopDocsCollector<FieldValueHitQueue.Entry>
-
newTopDocs
Description copied from class:TopDocsCollectorReturns aTopDocsinstance containing the given results. Ifresultsis 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.- Overrides:
newTopDocsin classTopDocsCollector<FieldValueHitQueue.Entry>
-
topDocs
Description copied from class:TopDocsCollectorReturns the top docs that were collected by this collector.- Overrides:
topDocsin classTopDocsCollector<FieldValueHitQueue.Entry>
-
isEarlyTerminated
public boolean isEarlyTerminated()Return whether collection terminated early.
-
TopFieldCollectorManagerdue to its support for concurrency in IndexSearcher