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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
FieldsFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract QueryPhaseRankCoordinatorContext
buildQueryPhaseCoordinatorContext
(int size, int from) Generates a context used to be executed on the coordinating node, that would combine all individual shard results.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.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.abstract RankFeaturePhaseRankShardContext
Generates a context used to execute the rank feature phase on the shard.protected abstract boolean
doEquals
(RankBuilder other) protected abstract int
protected abstract void
doWriteTo
(StreamOutput out) protected abstract void
doXContent
(XContentBuilder builder, ToXContent.Params params) final boolean
abstract org.apache.lucene.search.Explanation
explainHit
(org.apache.lucene.search.Explanation baseExplanation, RankDoc scoreDoc, List<String> queryNames) Generates anExplanation
on how the final score for the providedRankDoc
is computed for the given `RankBuilder`.final int
hashCode()
abstract boolean
Specify whether this rank builder is a compound builder or not.int
toString()
final XContentBuilder
toXContent
(XContentBuilder builder, ToXContent.Params params) final void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
Methods inherited from interface org.elasticsearch.common.io.stream.VersionedNamedWriteable
getMinimalSupportedVersion, getWriteableName
-
Field Details
-
RANK_WINDOW_SIZE_FIELD
-
DEFAULT_RANK_WINDOW_SIZE
public static final int DEFAULT_RANK_WINDOW_SIZE- See Also:
-
-
Constructor Details
-
RankBuilder
public RankBuilder(int rankWindowSize) -
RankBuilder
- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
doWriteTo
- Throws:
IOException
-
toXContent
public final XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- 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 anExplanation
on how the final score for the providedRankDoc
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
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 appropriateRankShardResult
. -
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
-
doEquals
-
hashCode
public final int hashCode() -
doHashCode
protected abstract int doHashCode() -
toString
-