Class RankBuilder

java.lang.Object
org.elasticsearch.search.rank.RankBuilder
All Implemented Interfaces:
NamedWriteable, VersionedNamedWriteable, Writeable, ToXContent, ToXContentObject

public abstract class RankBuilder extends Object implements VersionedNamedWriteable, ToXContentObject
RankBuilder is used as a base class to manage input, parsing, and subsequent generation of appropriate contexts for handling searches that require multiple queries and/or ranking steps for global rank relevance.
  • Field Details

    • RANK_WINDOW_SIZE_FIELD

      public static final ParseField RANK_WINDOW_SIZE_FIELD
    • DEFAULT_RANK_WINDOW_SIZE

      public static final int DEFAULT_RANK_WINDOW_SIZE
      See Also:
  • Constructor Details

  • Method Details

    • writeTo

      public final void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • doWriteTo

      protected abstract void doWriteTo(StreamOutput out) throws IOException
      Throws:
      IOException
    • toXContent

      public final XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      IOException
    • doXContent

      protected abstract void doXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Throws:
      IOException
    • rankWindowSize

      public int rankWindowSize()
    • isCompoundBuilder

      public abstract boolean isCompoundBuilder()
      Specify whether this rank builder is a compound builder or not. A compound builder is a rank builder that requires two or more queries to be executed in order to generate the final result.
    • explainHit

      public abstract org.apache.lucene.search.Explanation explainHit(org.apache.lucene.search.Explanation baseExplanation, RankDoc scoreDoc, List<String> queryNames)
      Generates an Explanation on how the final score for the provided RankDoc is computed for the given `RankBuilder`. In addition to the base explanation to enrich, we also have access to the query names that were provided in the request, so that we can have direct association with the user provided query.
    • buildQueryPhaseShardContext

      public abstract QueryPhaseRankShardContext buildQueryPhaseShardContext(List<org.apache.lucene.search.Query> queries, int from)
      Generates a context used to execute required searches during the query phase on the shard.
    • buildQueryPhaseCoordinatorContext

      public abstract QueryPhaseRankCoordinatorContext buildQueryPhaseCoordinatorContext(int size, int from)
      Generates a context used to be executed on the coordinating node, that would combine all individual shard results.
    • buildRankFeaturePhaseShardContext

      public abstract RankFeaturePhaseRankShardContext buildRankFeaturePhaseShardContext()
      Generates a context used to execute the rank feature phase on the shard. This is responsible for retrieving any needed feature data, and passing them back to the coordinator through the appropriate RankShardResult.
    • buildRankFeaturePhaseCoordinatorContext

      public abstract RankFeaturePhaseRankCoordinatorContext buildRankFeaturePhaseCoordinatorContext(int size, int from, Client client)
      Generates a context used to perform global ranking during the RankFeature phase, on the coordinator based on all the individual shard results. The output of this will be a `size` ranked list of ordered results, which will then be passed to fetch phase.
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • doEquals

      protected abstract boolean doEquals(RankBuilder other)
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • doHashCode

      protected abstract int doHashCode()
    • toString

      public String toString()
      Overrides:
      toString in class Object