java.lang.Object
org.apache.lucene.search.Query
org.elasticsearch.search.retriever.rankdoc.RankDocsQuery

public class RankDocsQuery extends org.apache.lucene.search.Query
A RankDocsQuery returns the top k documents in the order specified by the global doc IDs. This is used by retrievers that compute a score for a large document set, and need access to just the top results, after performing any reranking or filtering.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A Query that matches only the specified RankDoc, using the provided Query sources solely for the purpose of explainability.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RankDocsQuery(org.apache.lucene.index.IndexReader reader, RankDoc[] rankDocs, org.apache.lucene.search.Query[] sources, String[] queryNames, boolean onlyRankDocs)
    Creates a RankDocsQuery based on the provided docs.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.lucene.search.Weight
    createWeight(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost)
     
    boolean
     
    int
     
     
    org.apache.lucene.search.Query
    rewrite(org.apache.lucene.search.IndexSearcher searcher)
     
     
    void
    visit(org.apache.lucene.search.QueryVisitor visitor)
     

    Methods inherited from class org.apache.lucene.search.Query

    classHash, sameClassAs, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RankDocsQuery

      public RankDocsQuery(org.apache.lucene.index.IndexReader reader, RankDoc[] rankDocs, org.apache.lucene.search.Query[] sources, String[] queryNames, boolean onlyRankDocs)
      Creates a RankDocsQuery based on the provided docs.
      Parameters:
      rankDocs - The global doc IDs of documents that match, in ascending order
      sources - The original queries that were used to compute the top documents
      queryNames - The names (if present) of the original retrievers
      onlyRankDocs - Whether the query should only match the provided rank docs
  • Method Details

    • rankDocs

      public RankDoc[] rankDocs()
    • rewrite

      public org.apache.lucene.search.Query rewrite(org.apache.lucene.search.IndexSearcher searcher) throws IOException
      Overrides:
      rewrite in class org.apache.lucene.search.Query
      Throws:
      IOException
    • createWeight

      public org.apache.lucene.search.Weight createWeight(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost) throws IOException
      Overrides:
      createWeight in class org.apache.lucene.search.Query
      Throws:
      IOException
    • toString

      public String toString(String field)
      Specified by:
      toString in class org.apache.lucene.search.Query
    • visit

      public void visit(org.apache.lucene.search.QueryVisitor visitor)
      Specified by:
      visit in class org.apache.lucene.search.Query
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in class org.apache.lucene.search.Query
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class org.apache.lucene.search.Query