Package org.apache.lucene.search
Class TopFieldCollector
- java.lang.Object
-
- org.apache.lucene.search.Collector
-
- org.apache.lucene.search.TopDocsCollector<FieldValueHitQueue.Entry>
-
- org.apache.lucene.search.TopFieldCollector
-
public abstract class TopFieldCollector extends TopDocsCollector<FieldValueHitQueue.Entry>
ACollector
that sorts bySortField
usingFieldComparator
s. See thecreate(org.apache.lucene.search.Sort, int, boolean, boolean, boolean, boolean)
method for instantiating a TopFieldCollector.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptsDocsOutOfOrder()
Returntrue
if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) toCollector.collect(int)
.static TopFieldCollector
create(Sort sort, int numHits, boolean fillFields, boolean trackDocScores, boolean trackMaxScore, boolean docsScoredInOrder)
Creates a newTopFieldCollector
from the given arguments.static TopFieldCollector
create(Sort sort, int numHits, FieldDoc after, boolean fillFields, boolean trackDocScores, boolean trackMaxScore, boolean docsScoredInOrder)
Creates a newTopFieldCollector
from the given arguments.-
Methods inherited from class org.apache.lucene.search.TopDocsCollector
getTotalHits, topDocs, topDocs, topDocs
-
Methods inherited from class org.apache.lucene.search.Collector
collect, setNextReader, setScorer
-
-
-
-
Method Detail
-
create
public static TopFieldCollector create(Sort sort, int numHits, boolean fillFields, boolean trackDocScores, boolean trackMaxScore, boolean docsScoredInOrder) throws java.io.IOException
Creates a newTopFieldCollector
from 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.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 resultingTopDocs
. 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 setstrackDocScores
to true as well.docsScoredInOrder
- specifies whether documents are scored in doc Id order or not by the givenScorer
inCollector.setScorer(Scorer)
.- Returns:
- a
TopFieldCollector
instance which will sort the results by the sort criteria. - Throws:
java.io.IOException
- if there is a low-level I/O error
-
create
public static TopFieldCollector create(Sort sort, int numHits, FieldDoc after, boolean fillFields, boolean trackDocScores, boolean trackMaxScore, boolean docsScoredInOrder) throws java.io.IOException
Creates a newTopFieldCollector
from 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 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 resultingTopDocs
. 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 setstrackDocScores
to true as well.docsScoredInOrder
- specifies whether documents are scored in doc Id order or not by the givenScorer
inCollector.setScorer(Scorer)
.- Returns:
- a
TopFieldCollector
instance which will sort the results by the sort criteria. - Throws:
java.io.IOException
- if there is a low-level I/O error
-
acceptsDocsOutOfOrder
public boolean acceptsDocsOutOfOrder()
Description copied from class:Collector
Returntrue
if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) toCollector.collect(int)
.Most Lucene Query implementations will visit matching docIDs in order. However, some queries (currently limited to certain cases of
BooleanQuery
) can achieve faster searching if theCollector
allows them to deliver the docIDs out of order.Many collectors don't mind getting docIDs out of order, so it's important to return
true
here.- Specified by:
acceptsDocsOutOfOrder
in classCollector
-
-