Package org.apache.lucene.search
Class TopDocs
java.lang.Object
org.apache.lucene.search.TopDocs
- Direct Known Subclasses:
TopFieldDocs,TopSuggestDocs
Represents hits returned by
IndexSearcher.search(Query,int).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classprivate static final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TopDocsSame asmerge(int, TopDocs[])but also ignores the topstarttop docs.static TopDocsReturns a new TopDocs, containing topN results across the provided TopDocs, sorting by score.static TopFieldDocsmerge(Sort sort, int start, int topN, TopFieldDocs[] shardHits, boolean setShardIndex) Same asmerge(Sort, int, TopFieldDocs[])but also ignores the topstarttop docs.static TopFieldDocsmerge(Sort sort, int topN, TopFieldDocs[] shardHits) Returns a new TopFieldDocs, containing topN results across the provided TopFieldDocs, sorting by the specifiedSort.private static TopDocsAuxiliary method used by themerge(int, org.apache.lucene.search.TopDocs[])impls.(package private) static booleantieBreakLessThan(TopDocs.ShardRef first, ScoreDoc firstDoc, TopDocs.ShardRef second, ScoreDoc secondDoc) if we need to tie-break since score / sort value are the same we first compare shard index (lower shard wins) and then iff shard index is the same we use the hit index.
-
Field Details
-
totalHits
The total number of hits for the query. -
scoreDocs
The top hits for the query.
-
-
Constructor Details
-
TopDocs
Constructs a TopDocs.
-
-
Method Details
-
tieBreakLessThan
static boolean tieBreakLessThan(TopDocs.ShardRef first, ScoreDoc firstDoc, TopDocs.ShardRef second, ScoreDoc secondDoc) if we need to tie-break since score / sort value are the same we first compare shard index (lower shard wins) and then iff shard index is the same we use the hit index. -
merge
Returns a new TopDocs, containing topN results across the provided TopDocs, sorting by score. EachTopDocsinstance must be sorted.- See Also:
-
merge
Same asmerge(int, TopDocs[])but also ignores the topstarttop docs. This is typically useful for pagination. Note: IfsetShardIndexis true, this method will assume the incoming order ofshardHitsreflects each shard's index and will fill theScoreDoc.shardIndex, otherwise it must already be set for all incomingScoreDocs, which can be useful when doing multiple reductions (merges) of TopDocs. -
merge
Returns a new TopFieldDocs, containing topN results across the provided TopFieldDocs, sorting by the specifiedSort. Each of the TopDocs must have been sorted by the same Sort, and sort field values must have been filled (ie,fillFields=truemust be passed toTopFieldCollector.create(org.apache.lucene.search.Sort, int, int)).- See Also:
-
merge
public static TopFieldDocs merge(Sort sort, int start, int topN, TopFieldDocs[] shardHits, boolean setShardIndex) Same asmerge(Sort, int, TopFieldDocs[])but also ignores the topstarttop docs. This is typically useful for pagination. Note: IfsetShardIndexis true, this method will assume the incoming order ofshardHitsreflects each shard's index and will fill theScoreDoc.shardIndex, otherwise it must already be set for all incomingScoreDocs, which can be useful when doing multiple reductions (merges) of TopDocs. -
mergeAux
private static TopDocs mergeAux(Sort sort, int start, int size, TopDocs[] shardHits, boolean setShardIndex) Auxiliary method used by themerge(int, org.apache.lucene.search.TopDocs[])impls. A sort value of null is used to indicate that docs should be sorted by score.
-