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 class
private static class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Comparator
<ScoreDoc> Default comparatorprivate static final Comparator
<ScoreDoc> Internal comparator with docIDScoreDoc[]
The top hits for the query.private static final Comparator
<ScoreDoc> Internal comparator with shardIndexThe total number of hits for the query. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TopDocs
Same asmerge(int, TopDocs[])
but also ignores the topstart
top docs.static TopDocs
merge
(int start, int topN, TopDocs[] shardHits, Comparator<ScoreDoc> tieBreaker) Same as above, but accepts the passed in tie breakerstatic TopDocs
Returns a new TopDocs, containing topN results across the provided TopDocs, sorting by score.static TopFieldDocs
merge
(Sort sort, int start, int topN, TopFieldDocs[] shardHits) Same asmerge(Sort, int, TopFieldDocs[])
but also ignores the topstart
top docs.static TopFieldDocs
merge
(Sort sort, int start, int topN, TopFieldDocs[] shardHits, Comparator<ScoreDoc> tieBreaker) Pass in a custom tie breaker for ordering resultsstatic TopFieldDocs
merge
(Sort sort, int topN, TopFieldDocs[] shardHits) Returns a new TopFieldDocs, containing topN results across the provided TopFieldDocs, sorting by the specifiedSort
.private static TopDocs
mergeAux
(Sort sort, int start, int size, TopDocs[] shardHits, Comparator<ScoreDoc> tieBreaker) Auxiliary method used by themerge(int, org.apache.lucene.search.TopDocs[])
impls.(package private) static boolean
tieBreakLessThan
(TopDocs.ShardRef first, ScoreDoc firstDoc, TopDocs.ShardRef second, ScoreDoc secondDoc, Comparator<ScoreDoc> tieBreaker) Use the tie breaker if provided.
-
Field Details
-
totalHits
The total number of hits for the query. -
scoreDocs
The top hits for the query. -
SHARD_INDEX_TIE_BREAKER
Internal comparator with shardIndex -
DOC_ID_TIE_BREAKER
Internal comparator with docID -
DEFAULT_TIE_BREAKER
Default comparator
-
-
Constructor Details
-
TopDocs
Constructs a TopDocs.
-
-
Method Details
-
tieBreakLessThan
static boolean tieBreakLessThan(TopDocs.ShardRef first, ScoreDoc firstDoc, TopDocs.ShardRef second, ScoreDoc secondDoc, Comparator<ScoreDoc> tieBreaker) Use the tie breaker if provided. If tie breaker returns 0 signifying equal values, we use hit indices to tie break intra shard ties -
merge
Returns a new TopDocs, containing topN results across the provided TopDocs, sorting by score. EachTopDocs
instance must be sorted.- See Also:
-
merge
Same asmerge(int, TopDocs[])
but also ignores the topstart
top docs. This is typically useful for pagination.docIDs are expected to be in consistent pattern i.e. either all ScoreDocs have their shardIndex set, or all have them as -1 (signifying that all hits belong to same searcher)
-
merge
public static TopDocs merge(int start, int topN, TopDocs[] shardHits, Comparator<ScoreDoc> tieBreaker) Same as above, but accepts the passed in tie breakerdocIDs are expected to be in consistent pattern i.e. either all ScoreDocs have their shardIndex set, or all have them as -1 (signifying that all hits belong to same searcher)
-
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.- See Also:
-
merge
Same asmerge(Sort, int, TopFieldDocs[])
but also ignores the topstart
top docs. This is typically useful for pagination.docIDs are expected to be in consistent pattern i.e. either all ScoreDocs have their shardIndex set, or all have them as -1 (signifying that all hits belong to same searcher)
-
merge
public static TopFieldDocs merge(Sort sort, int start, int topN, TopFieldDocs[] shardHits, Comparator<ScoreDoc> tieBreaker) Pass in a custom tie breaker for ordering results -
mergeAux
private static TopDocs mergeAux(Sort sort, int start, int size, TopDocs[] shardHits, Comparator<ScoreDoc> tieBreaker) 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.
-