Class TopDocs

    • Field Detail

      • totalHits

        public TotalHits totalHits
        The total number of hits for the query.
      • scoreDocs

        public ScoreDoc[] scoreDocs
        The top hits for the query.
    • Constructor Detail

      • TopDocs

        public TopDocs​(TotalHits totalHits,
                       ScoreDoc[] scoreDocs)
        Constructs a TopDocs.
    • Method Detail

      • 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

        public static TopDocs merge​(int start,
                                    int topN,
                                    TopDocs[] shardHits,
                                    boolean setShardIndex)
        Same as merge(int, TopDocs[]) but also ignores the top start top docs. This is typically useful for pagination. Note: If setShardIndex is true, this method will assume the incoming order of shardHits reflects each shard's index and will fill the ScoreDoc.shardIndex, otherwise it must already be set for all incoming ScoreDocs, which can be useful when doing multiple reductions (merges) of TopDocs.
      • merge

        public static TopFieldDocs merge​(Sort sort,
                                         int start,
                                         int topN,
                                         TopFieldDocs[] shardHits,
                                         boolean setShardIndex)
        Same as merge(Sort, int, TopFieldDocs[]) but also ignores the top start top docs. This is typically useful for pagination. Note: If setShardIndex is true, this method will assume the incoming order of shardHits reflects each shard's index and will fill the ScoreDoc.shardIndex, otherwise it must already be set for all incoming ScoreDocs, which can be useful when doing multiple reductions (merges) of TopDocs.