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, boolean, boolean, boolean)
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) int |
docBase |
private static ScoreDoc[] |
EMPTY_SCOREDOCS |
private boolean |
fillFields |
(package private) float |
maxScore |
(package private) boolean |
needsScores |
(package private) int |
numHits |
(package private) boolean |
queueFull |
EMPTY_TOPDOCS, pq, totalHits
Modifier | Constructor and Description |
---|---|
private |
TopFieldCollector(PriorityQueue<FieldValueHitQueue.Entry> pq,
int numHits,
boolean fillFields,
boolean needsScores) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
add(int slot,
int doc,
float score) |
static TopFieldCollector |
create(Sort sort,
int numHits,
boolean fillFields,
boolean trackDocScores,
boolean trackMaxScore)
Creates a new
TopFieldCollector from the given
arguments. |
static TopFieldCollector |
create(Sort sort,
int numHits,
FieldDoc after,
boolean fillFields,
boolean trackDocScores,
boolean trackMaxScore)
Creates a new
TopFieldCollector from the given
arguments. |
boolean |
needsScores()
Indicates if document scores are needed by this collector.
|
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.
|
TopFieldDocs |
topDocs()
Returns the top docs that were collected by this collector.
|
(package private) void |
updateBottom(int doc) |
(package private) void |
updateBottom(int doc,
float score) |
getTotalHits, topDocs, topDocs, topDocsSize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLeafCollector
private static final ScoreDoc[] EMPTY_SCOREDOCS
private final boolean fillFields
float maxScore
final int numHits
FieldValueHitQueue.Entry bottom
boolean queueFull
int docBase
final boolean needsScores
private TopFieldCollector(PriorityQueue<FieldValueHitQueue.Entry> pq, int numHits, boolean fillFields, boolean needsScores)
public boolean needsScores()
Collector
true
if scores are needed.public static TopFieldCollector create(Sort sort, int numHits, boolean fillFields, boolean trackDocScores, boolean trackMaxScore)
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.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 Float.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 Float.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.TopFieldCollector
instance which will sort the results by
the sort criteria.public static TopFieldCollector create(Sort sort, int numHits, FieldDoc after, boolean fillFields, boolean trackDocScores, boolean trackMaxScore)
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 collectedfillFields
- 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 Float.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 Float.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.TopFieldCollector
instance which will sort the results by
the sort criteria.final void add(int slot, int doc, float score)
final void updateBottom(int doc)
final void updateBottom(int doc, float score)
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>