Package org.apache.lucene.search
Class TopDocs
- java.lang.Object
-
- org.apache.lucene.search.TopDocs
-
- Direct Known Subclasses:
TopFieldDocs
public class TopDocs extends Object
Represents hits returned byIndexSearcher.search(Query,int).
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TopDocsmerge(int start, int topN, TopDocs[] shardHits, boolean setShardIndex)Same asmerge(int, TopDocs[])but also ignores the topstarttop docs.static TopDocsmerge(int topN, TopDocs[] shardHits)Returns 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.
-
-
-
Method Detail
-
merge
public static TopDocs merge(int topN, TopDocs[] shardHits)
Returns a new TopDocs, containing topN results across the provided TopDocs, sorting by score. EachTopDocsinstance must be sorted.- See Also:
merge(int, int, TopDocs[], boolean)- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
merge
public static TopDocs merge(int start, int topN, TopDocs[] shardHits, boolean setShardIndex)
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.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
merge
public static TopFieldDocs merge(Sort sort, int topN, TopFieldDocs[] shardHits)
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(Sort, int, int, TopFieldDocs[], boolean)- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
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.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-