Module org.elasticsearch.server
Class CompoundRetrieverBuilder<T extends CompoundRetrieverBuilder<T>>
java.lang.Object
org.elasticsearch.search.retriever.RetrieverBuilder
org.elasticsearch.search.retriever.CompoundRetrieverBuilder<T>
- All Implemented Interfaces:
Rewriteable<RetrieverBuilder>
,ToXContent
- Direct Known Subclasses:
RescorerRetrieverBuilder
public abstract class CompoundRetrieverBuilder<T extends CompoundRetrieverBuilder<T>>
extends RetrieverBuilder
This abstract retriever defines a compound retriever. The idea is that it is not a leaf-retriever, i.e. it does not
perform actual searches itself. Instead, it is a container for a set of child retrievers and is responsible for combining
the results of the child retrievers according to the implementation of
combineQueryPhaseResults
.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final NodeFeature
protected final List
<CompoundRetrieverBuilder.RetrieverSource> static final ParseField
protected final int
Fields inherited from class org.elasticsearch.search.retriever.RetrieverBuilder
MIN_SCORE_FIELD, minScore, NAME_FIELD, PRE_FILTER_FIELD, preFilterQueryBuilders, rankDocs, retrieverName, RETRIEVERS_SUPPORTED
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CompoundRetrieverBuilder
(List<CompoundRetrieverBuilder.RetrieverSource> innerRetrievers, int rankWindowSize) -
Method Summary
Modifier and TypeMethodDescriptionaddChild
(RetrieverBuilder retrieverBuilder) protected abstract T
clone
(List<CompoundRetrieverBuilder.RetrieverSource> newChildRetrievers, List<QueryBuilder> newPreFilterQueryBuilders) Returns a clone of the original retriever, replacing the sub-retrievers with the providednewChildRetrievers
and the filters with thenewPreFilterQueryBuilders
.protected abstract RankDoc[]
combineInnerRetrieverResults
(List<org.apache.lucene.search.ScoreDoc[]> rankResults, boolean explain) Combines the providedrankResults
to return the final top documents.protected final SearchSourceBuilder
createSearchSourceBuilder
(PointInTimeBuilder pit, RetrieverBuilder retrieverBuilder) boolean
int
final QueryBuilder
final void
extractToSearchSourceBuilder
(SearchSourceBuilder searchSourceBuilder, boolean compoundUsed) This method is called at the end of rewriting on behalf of aSearchSourceBuilder
.protected SearchSourceBuilder
finalizeSourceBuilder
(SearchSourceBuilder sourceBuilder) Retrieves theParseField
used to configure therankWindowSize
at the REST layer.final boolean
Determines if this retriever contains sub-retrievers that need to be executed prior to search.final RetrieverBuilder
Rewrites this instance based on the provided context.final QueryBuilder
This function is called by compoundRetrieverBuilder
to return the original query that was used by this retriever to compute its top documents.validate
(SearchSourceBuilder source, ActionRequestValidationException validationException, boolean isScroll, boolean allowPartialSearchResults) Methods inherited from class org.elasticsearch.search.retriever.RetrieverBuilder
declareBaseParserFields, doToXContent, equals, getName, getPreFilterQueryBuilders, getRankDocs, hashCode, isFragment, minScore, minScore, parseInnerRetrieverBuilder, parseTopLevelRetrieverBuilder, retrieverName, retrieverName, rewritePreFilters, setRankDocs, toString, toXContent
-
Field Details
-
INNER_RETRIEVERS_FILTER_SUPPORT
-
RANK_WINDOW_SIZE_FIELD
-
rankWindowSize
protected final int rankWindowSize -
innerRetrievers
-
-
Constructor Details
-
CompoundRetrieverBuilder
protected CompoundRetrieverBuilder(List<CompoundRetrieverBuilder.RetrieverSource> innerRetrievers, int rankWindowSize)
-
-
Method Details
-
addChild
-
clone
protected abstract T clone(List<CompoundRetrieverBuilder.RetrieverSource> newChildRetrievers, List<QueryBuilder> newPreFilterQueryBuilders) Returns a clone of the original retriever, replacing the sub-retrievers with the providednewChildRetrievers
and the filters with thenewPreFilterQueryBuilders
. -
combineInnerRetrieverResults
protected abstract RankDoc[] combineInnerRetrieverResults(List<org.apache.lucene.search.ScoreDoc[]> rankResults, boolean explain) Combines the providedrankResults
to return the final top documents. -
isCompound
public final boolean isCompound()Description copied from class:RetrieverBuilder
Determines if this retriever contains sub-retrievers that need to be executed prior to search.- Overrides:
isCompound
in classRetrieverBuilder
-
getRankWindowSizeField
Retrieves theParseField
used to configure therankWindowSize
at the REST layer. -
rewrite
Description copied from interface:Rewriteable
Rewrites this instance based on the provided context. The returned objects will be the same instance as this if no changes during the rewrite were applied.- Specified by:
rewrite
in interfaceRewriteable<T extends CompoundRetrieverBuilder<T>>
- Overrides:
rewrite
in classRetrieverBuilder
- Throws:
IOException
-
topDocsQuery
Description copied from class:RetrieverBuilder
This function is called by compoundRetrieverBuilder
to return the original query that was used by this retriever to compute its top documents.- Specified by:
topDocsQuery
in classRetrieverBuilder
-
explainQuery
- Overrides:
explainQuery
in classRetrieverBuilder
-
extractToSearchSourceBuilder
public final void extractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder, boolean compoundUsed) Description copied from class:RetrieverBuilder
This method is called at the end of rewriting on behalf of aSearchSourceBuilder
. Elements from retrievers are expected to be "extracted" into theSearchSourceBuilder
.- Specified by:
extractToSearchSourceBuilder
in classRetrieverBuilder
-
validate
public ActionRequestValidationException validate(SearchSourceBuilder source, ActionRequestValidationException validationException, boolean isScroll, boolean allowPartialSearchResults) - Overrides:
validate
in classRetrieverBuilder
-
doEquals
- Specified by:
doEquals
in classRetrieverBuilder
-
doHashCode
public int doHashCode()- Specified by:
doHashCode
in classRetrieverBuilder
-
createSearchSourceBuilder
protected final SearchSourceBuilder createSearchSourceBuilder(PointInTimeBuilder pit, RetrieverBuilder retrieverBuilder) -
finalizeSourceBuilder
-