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 NodeFeatureprotected final List<CompoundRetrieverBuilder.RetrieverSource> static final ParseFieldprotected final intFields inherited from class org.elasticsearch.search.retriever.RetrieverBuilder
MIN_SCORE_FIELD, minScore, NAME_FIELD, PRE_FILTER_FIELD, preFilterQueryBuilders, rankDocs, retrieverNameFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCompoundRetrieverBuilder(List<CompoundRetrieverBuilder.RetrieverSource> innerRetrievers, int rankWindowSize) -
Method Summary
Modifier and TypeMethodDescriptionaddChild(RetrieverBuilder retrieverBuilder) protected abstract Tclone(List<CompoundRetrieverBuilder.RetrieverSource> newChildRetrievers, List<QueryBuilder> newPreFilterQueryBuilders) Returns a clone of the original retriever, replacing the sub-retrievers with the providednewChildRetrieversand the filters with thenewPreFilterQueryBuilders.protected abstract RankDoc[]combineInnerRetrieverResults(List<org.apache.lucene.search.ScoreDoc[]> rankResults, boolean explain) Combines the providedrankResultsto return the final top documents.protected final SearchSourceBuildercreateSearchSourceBuilder(PointInTimeBuilder pit, RetrieverBuilder retrieverBuilder) booleanintprotected RetrieverBuilderPerform any custom rewrite logic necessaryfinal QueryBuilderfinal voidextractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder, boolean compoundUsed) This method is called at the end of rewriting on behalf of aSearchSourceBuilder.protected SearchSourceBuilderfinalizeSourceBuilder(SearchSourceBuilder sourceBuilder) Retrieves theParseFieldused to configure therankWindowSizeat the REST layer.final booleanDetermines if this retriever contains sub-retrievers that need to be executed prior to search.intfinal RetrieverBuilderRewrites this instance based on the provided context.final QueryBuilderThis function is called by compoundRetrieverBuilderto 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 providednewChildRetrieversand the filters with thenewPreFilterQueryBuilders. -
combineInnerRetrieverResults
protected abstract RankDoc[] combineInnerRetrieverResults(List<org.apache.lucene.search.ScoreDoc[]> rankResults, boolean explain) Combines the providedrankResultsto return the final top documents. -
isCompound
public final boolean isCompound()Description copied from class:RetrieverBuilderDetermines if this retriever contains sub-retrievers that need to be executed prior to search.- Overrides:
isCompoundin classRetrieverBuilder
-
getRankWindowSizeField
Retrieves theParseFieldused to configure therankWindowSizeat the REST layer. -
rewrite
Description copied from interface:RewriteableRewrites 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:
rewritein interfaceRewriteable<T extends CompoundRetrieverBuilder<T>>- Overrides:
rewritein classRetrieverBuilder- Throws:
IOException
-
topDocsQuery
Description copied from class:RetrieverBuilderThis function is called by compoundRetrieverBuilderto return the original query that was used by this retriever to compute its top documents.- Specified by:
topDocsQueryin classRetrieverBuilder
-
explainQuery
- Overrides:
explainQueryin classRetrieverBuilder
-
extractToSearchSourceBuilder
public final void extractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder, boolean compoundUsed) Description copied from class:RetrieverBuilderThis method is called at the end of rewriting on behalf of aSearchSourceBuilder. Elements from retrievers are expected to be "extracted" into theSearchSourceBuilder.- Specified by:
extractToSearchSourceBuilderin classRetrieverBuilder
-
validate
public ActionRequestValidationException validate(SearchSourceBuilder source, ActionRequestValidationException validationException, boolean isScroll, boolean allowPartialSearchResults) - Overrides:
validatein classRetrieverBuilder
-
doEquals
- Specified by:
doEqualsin classRetrieverBuilder
-
doHashCode
public int doHashCode()- Specified by:
doHashCodein classRetrieverBuilder
-
rankWindowSize
public int rankWindowSize() -
innerRetrievers
-
createSearchSourceBuilder
protected final SearchSourceBuilder createSearchSourceBuilder(PointInTimeBuilder pit, RetrieverBuilder retrieverBuilder) -
finalizeSourceBuilder
-
doRewrite
Perform any custom rewrite logic necessary- Parameters:
ctx- The query rewrite context- Returns:
- RetrieverBuilder the rewritten retriever
-