public abstract class TopFieldCollector extends TopDocsCollector<FieldValueHitQueue.Entry>
Collector
that sorts by SortField
using
FieldComparator
s.
See the create(org.apache.lucene.search.Sort, int, int)
method
for instantiating a TopFieldCollector.
Modifier and Type | Class and Description |
---|---|
private static class |
TopFieldCollector.MultiComparatorLeafCollector |
private static class |
TopFieldCollector.PagingFieldCollector |
private static class |
TopFieldCollector.SimpleFieldCollector |
Modifier and Type | Field and Description |
---|---|
(package private) FieldValueHitQueue.Entry |
bottom |
(package private) boolean |
canSetMinScore |
(package private) int |
docBase |
private static ScoreDoc[] |
EMPTY_SCOREDOCS |
(package private) FieldComparator.RelevanceComparator |
firstComparator |
(package private) boolean |
needsScores |
(package private) int |
numComparators |
(package private) int |
numHits |
(package private) boolean |
queueFull |
(package private) ScoreMode |
scoreMode |
(package private) int |
totalHitsThreshold |
EMPTY_TOPDOCS, pq, totalHits, totalHitsRelation
Modifier | Constructor and Description |
---|---|
private |
TopFieldCollector(FieldValueHitQueue<FieldValueHitQueue.Entry> pq,
int numHits,
int totalHitsThreshold,
boolean needsScores) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
add(int slot,
int doc) |
(package private) static boolean |
canEarlyTerminate(Sort searchSort,
Sort indexSort) |
private static boolean |
canEarlyTerminateOnDocId(Sort searchSort) |
private static boolean |
canEarlyTerminateOnPrefix(Sort searchSort,
Sort indexSort) |
static TopFieldCollector |
create(Sort sort,
int numHits,
FieldDoc after,
int totalHitsThreshold)
Creates a new
TopFieldCollector from the given
arguments. |
static TopFieldCollector |
create(Sort sort,
int numHits,
int totalHitsThreshold)
Creates a new
TopFieldCollector from the given
arguments. |
boolean |
isEarlyTerminated()
Return whether collection terminated early.
|
protected TopDocs |
newTopDocs(ScoreDoc[] results,
int start)
Returns a
TopDocs instance containing the given results. |
protected void |
populateResults(ScoreDoc[] results,
int howMany)
Populates the results array with the ScoreDoc instances.
|
static void |
populateScores(ScoreDoc[] topDocs,
IndexSearcher searcher,
Query query)
Populate
scores of the given topDocs . |
ScoreMode |
scoreMode()
Indicates what features are required from the scorer.
|
TopFieldDocs |
topDocs()
Returns the top docs that were collected by this collector.
|
(package private) void |
updateBottom(int doc) |
protected void |
updateMinCompetitiveScore(Scorable scorer) |
getTotalHits, topDocs, topDocs, topDocsSize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLeafCollector
private static final ScoreDoc[] EMPTY_SCOREDOCS
final int numHits
final int totalHitsThreshold
final FieldComparator.RelevanceComparator firstComparator
final boolean canSetMinScore
final int numComparators
FieldValueHitQueue.Entry bottom
boolean queueFull
int docBase
final boolean needsScores
final ScoreMode scoreMode
private TopFieldCollector(FieldValueHitQueue<FieldValueHitQueue.Entry> pq, int numHits, int totalHitsThreshold, boolean needsScores)
private static boolean canEarlyTerminateOnDocId(Sort searchSort)
private static boolean canEarlyTerminateOnPrefix(Sort searchSort, Sort indexSort)
public ScoreMode scoreMode()
Collector
protected void updateMinCompetitiveScore(Scorable scorer) throws java.io.IOException
java.io.IOException
public static TopFieldCollector create(Sort sort, int numHits, int totalHitsThreshold)
TopFieldCollector
from the given
arguments.
NOTE: The instances returned by this method
pre-allocate a full array of length
numHits
.
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 than
totalHitsThreshold
hits then its hit count will be a
lower bound. On the other hand if the query matches less than or exactly
totalHitsThreshold
hits then the hit count of the result will
be accurate. Integer.MAX_VALUE
may be used to make the hit
count accurate, but this will also make query processing slower.TopFieldCollector
instance which will sort the results by
the sort criteria.public static TopFieldCollector create(Sort sort, int numHits, FieldDoc after, int totalHitsThreshold)
TopFieldCollector
from the given
arguments.
NOTE: The instances returned by this method
pre-allocate a full array of length
numHits
.
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 than
totalHitsThreshold
hits then its hit count will be a
lower bound. On the other hand if the query matches less than or exactly
totalHitsThreshold
hits then the hit count of the result will
be accurate. Integer.MAX_VALUE
may be used to make the hit
count accurate, but this will also make query processing slower.TopFieldCollector
instance which will sort the results by
the sort criteria.public static void populateScores(ScoreDoc[] topDocs, IndexSearcher searcher, Query query) throws java.io.IOException
scores
of the given topDocs
.topDocs
- the top docs to populatesearcher
- the index searcher that has been used to compute topDocs
query
- the query that has been used to compute topDocs
java.lang.IllegalArgumentException
- if there is evidence that topDocs
have been computed against a different searcher or a different query.java.io.IOException
final void add(int slot, int doc)
final void updateBottom(int doc)
protected void populateResults(ScoreDoc[] results, int howMany)
TopDocsCollector
populateResults
in class TopDocsCollector<FieldValueHitQueue.Entry>
protected TopDocs newTopDocs(ScoreDoc[] results, int start)
TopDocsCollector
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.newTopDocs
in class TopDocsCollector<FieldValueHitQueue.Entry>
public TopFieldDocs topDocs()
TopDocsCollector
topDocs
in class TopDocsCollector<FieldValueHitQueue.Entry>
public boolean isEarlyTerminated()