java.lang.Object
org.elasticsearch.search.retriever.RetrieverBuilder
- All Implemented Interfaces:
Rewriteable<RetrieverBuilder>,ToXContent
- Direct Known Subclasses:
CompoundRetrieverBuilder,KnnRetrieverBuilder,RankDocsRetrieverBuilder,RetrieverBuilderWrapper,StandardRetrieverBuilder
public abstract class RetrieverBuilder
extends Object
implements Rewriteable<RetrieverBuilder>, ToXContent
A retriever represents an API element that returns an ordered list of top
documents. These can be obtained from a query, from another retriever, etc.
Internally, a
RetrieverBuilder is first rewritten into its simplest
form and then its elements are extracted into a SearchSourceBuilder.
The advantage retrievers have is in the API they appear as a tree-like structure enabling
easier reasoning about what a search does.
This is the base class for all other retrievers. This class does not support
serialization and is expected to be fully extracted to a SearchSourceBuilder
prior to any transport calls.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ParseFieldprotected Floatstatic final ParseFieldstatic final ParseFieldprotected List<QueryBuilder> protected RankDoc[]protected StringFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voiddeclareBaseParserFields(AbstractObjectParser<? extends RetrieverBuilder, RetrieverParserContext> parser) protected abstract booleanprotected abstract intprotected abstract voiddoToXContent(XContentBuilder builder, ToXContent.Params params) final booleanabstract voidextractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder, boolean compoundUsed) This method is called at the end of rewriting on behalf of aSearchSourceBuilder.abstract StringgetName()Gets the filters for this retriever.RankDoc[]final inthashCode()booleanDetermines if this retriever contains sub-retrievers that need to be executed prior to search.booleanminScore()protected static RetrieverBuilderparseInnerRetrieverBuilder(XContentParser parser, RetrieverParserContext context) static RetrieverBuilderparseTopLevelRetrieverBuilder(XContentParser parser, RetrieverParserContext context) retrieverName(String retrieverName) Rewrites this instance based on the provided context.protected final List<QueryBuilder> voidsetRankDocs(RankDoc[] rankDocs) abstract QueryBuilderThis function is called by compoundRetrieverBuilderto return the original query that was used by this retriever to compute its top documents.toString()final XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params) validate(SearchSourceBuilder source, ActionRequestValidationException validationException, boolean isScroll, boolean allowPartialSearchResults)
-
Field Details
-
PRE_FILTER_FIELD
-
MIN_SCORE_FIELD
-
NAME_FIELD
-
preFilterQueryBuilders
-
retrieverName
-
minScore
-
rankDocs
-
-
Constructor Details
-
RetrieverBuilder
public RetrieverBuilder()
-
-
Method Details
-
declareBaseParserFields
protected static void declareBaseParserFields(AbstractObjectParser<? extends RetrieverBuilder, RetrieverParserContext> parser) -
retrieverName
-
minScore
-
parseTopLevelRetrieverBuilder
public static RetrieverBuilder parseTopLevelRetrieverBuilder(XContentParser parser, RetrieverParserContext context) throws IOException - Throws:
IOException
-
parseInnerRetrieverBuilder
protected static RetrieverBuilder parseInnerRetrieverBuilder(XContentParser parser, RetrieverParserContext context) throws IOException - Throws:
IOException
-
isCompound
public boolean isCompound()Determines if this retriever contains sub-retrievers that need to be executed prior to search. -
rewritePreFilters
- Throws:
IOException
-
topDocsQuery
This function is called by compoundRetrieverBuilderto return the original query that was used by this retriever to compute its top documents. -
explainQuery
-
minScore
-
setRankDocs
-
getRankDocs
-
getPreFilterQueryBuilders
Gets the filters for this retriever. -
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<RetrieverBuilder>- Throws:
IOException
-
extractToSearchSourceBuilder
public abstract void extractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder, boolean compoundUsed) This method is called at the end of rewriting on behalf of aSearchSourceBuilder. Elements from retrievers are expected to be "extracted" into theSearchSourceBuilder. -
validate
public ActionRequestValidationException validate(SearchSourceBuilder source, ActionRequestValidationException validationException, boolean isScroll, boolean allowPartialSearchResults) -
getName
-
toXContent
public final XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
doToXContent
protected abstract void doToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Throws:
IOException
-
isFragment
public boolean isFragment()- Specified by:
isFragmentin interfaceToXContent
-
equals
-
doEquals
-
hashCode
public final int hashCode() -
doHashCode
protected abstract int doHashCode() -
toString
-
retrieverName
-