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 ParseField
protected Float
static final ParseField
static final ParseField
protected List
<QueryBuilder> protected RankDoc[]
protected String
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
declareBaseParserFields
(String name, AbstractObjectParser<? extends RetrieverBuilder, RetrieverParserContext> parser) protected abstract boolean
protected abstract int
protected abstract void
doToXContent
(XContentBuilder builder, ToXContent.Params params) final boolean
abstract void
extractToSearchSourceBuilder
(SearchSourceBuilder searchSourceBuilder, boolean compoundUsed) This method is called at the end of rewriting on behalf of aSearchSourceBuilder
.abstract String
getName()
Gets the filters for this retriever.RankDoc[]
final int
hashCode()
boolean
Determines if this retriever contains sub-retrievers that need to be executed prior to search.boolean
minScore()
protected static RetrieverBuilder
parseInnerRetrieverBuilder
(XContentParser parser, RetrieverParserContext context) static RetrieverBuilder
parseTopLevelRetrieverBuilder
(XContentParser parser, RetrieverParserContext context) retrieverName
(String retrieverName) Rewrites this instance based on the provided context.protected final List
<QueryBuilder> void
setRankDocs
(RankDoc[] rankDocs) abstract QueryBuilder
This function is called by compoundRetrieverBuilder
to return the original query that was used by this retriever to compute its top documents.toString()
final XContentBuilder
toXContent
(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(String name, 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 compoundRetrieverBuilder
to 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: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<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:
toXContent
in interfaceToXContent
- Throws:
IOException
-
doToXContent
protected abstract void doToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Throws:
IOException
-
isFragment
public boolean isFragment()- Specified by:
isFragment
in interfaceToXContent
-
equals
-
doEquals
-
hashCode
public final int hashCode() -
doHashCode
protected abstract int doHashCode() -
toString
-
retrieverName
-