Run a search
- POST also GET /{index}/_search
- POST also GET /_search
Get search hits that match the query defined in the request.
You can provide search queries using the q query string parameter or the request body.
If both are specified, only the query parameter is used.
If the Elasticsearch security features are enabled, you must have the read index privilege for the target data stream, index, or alias. For cross-cluster search, refer to the documentation about configuring CCS privileges.
To search a point in time (PIT) for an alias, you must have the read index privilege for the alias's data streams or indices.
Search slicing
When paging through a large number of documents, it can be helpful to split the search into multiple slices to consume them independently with the slice and pit properties.
By default the splitting is done first on the shards, then locally on each shard.
The local splitting partitions the shard into contiguous ranges based on Lucene document IDs.
For instance if the number of shards is equal to 2 and you request 4 slices, the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 are assigned to the second shard.
IMPORTANT: The same point-in-time ID should be used for all slices. If different PIT IDs are used, slices can overlap and miss documents. This situation can occur because the splitting criterion is based on Lucene document IDs, which are not stable across changes to the index.
- Index privileges:
read
Path Parameters
-
indexIndexName | IndexNameoptional -
A comma-separated list of data streams, indices, and aliases to search. It supports wildcards (
*). To search all data streams and indices, omit this parameter or use*or_all.Leave it out to use
/_search.
Query Parameters
-
allow_no_indicesboolean · default: true If
false, the request returns an error if any wildcard expression, index alias, or_allvalue targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targetingfoo*,bar*returns an error if an index starts withfoobut no index starts withbar.-
allow_partial_search_resultsboolean · default: true If
trueand there are shard request timeouts or shard failures, the request returns partial results. Iffalse, it returns an error with no partial results.To override the default behavior, you can set the
search.default_allow_partial_resultscluster setting tofalse.-
analyzerstring The analyzer to use for the query string. This parameter can be used only when the
qquery string parameter is specified.-
analyze_wildcardboolean · default: false If
true, wildcard and prefix queries are analyzed. This parameter can be used only when theqquery string parameter is specified.-
batched_reduce_sizenumber · default: 512 The number of shard results that should be reduced at once on the coordinating node. If the potential number of shards in the request can be large, this value should be used as a protection mechanism to reduce the memory overhead per search request.
-
ccs_minimize_roundtripsboolean · default: true If
true, network round-trips between the coordinating node and the remote clusters are minimized when running cross-cluster search (CCS) requests.-
default_operatorOperator · default: or The default operator for the query string query:
andoror. This parameter can be used only when theqquery string parameter is specified.-
Values:
andANDorOR -
dfstring The field to use as a default when no field prefix is given in the query string. This parameter can be used only when the
qquery string parameter is specified.-
docvalue_fieldsFields A comma-separated list of fields to return as the docvalue representation of a field for each hit.
-
expand_wildcardsstring ExpandWildcards · default: open The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. It supports comma-separated values such as
open,hidden.Supported values include:
all: Match any data stream or index, including hidden ones.open: Match open, non-hidden indices. Also matches any non-hidden data stream.closed: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.hidden: Match hidden data streams and hidden indices. Must be combined withopen,closed, orboth.none: Wildcard expressions are not accepted.
-
Values:
allopenclosedhiddennone -
explainboolean · default: false If
true, the request returns detailed information about score computation as part of a hit.-
ignore_throttledboolean · default: truedeprecated If
true, concrete, expanded or aliased indices will be ignored when frozen.If
false, the request returns an error if it targets a missing or closed index.-
include_named_queries_scoreboolean · default: false If
true, the response includes the score contribution from any named queries.This functionality reruns each named query on every hit in a search response. Typically, this adds a small overhead to a request. However, using computationally expensive named queries on a large number of hits may add significant overhead.
-
lenientboolean · default: false If
true, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. This parameter can be used only when theqquery string parameter is specified.-
max_concurrent_shard_requestsnumber · default: 5 The number of concurrent shard requests per node that the search runs concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests.
-
min_compatible_shard_nodestring The minimum version of the node that can handle the request Any handling node with a lower version will fail the request.
-
preferencestring The nodes and shards used for the search. By default, Elasticsearch selects from eligible nodes and shards using adaptive replica selection, accounting for allocation awareness. Valid values are:
_only_localto run the search only on shards on the local node;_localto, if possible, run the search on shards on the local node, or if not, select shards using the default method;_only_nodes:<node-id>,<node-id>to run the search on only the specified nodes IDs, where, if suitable shards exist on more than one selected node, use shards on those nodes using the default method, or if none of the specified nodes are available, select shards from any available node using the default method;_prefer_nodes:<node-id>,<node-id>to if possible, run the search on the specified nodes IDs, or if not, select shards using the default method;_shards:<shard>,<shard>to run the search only on the specified shards;<custom-string>(any string that does not start with_) to route searches with the same<custom-string>to the same shards in the same order.
-
pre_filter_shard_sizenumber A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method (if date filters are mandatory to match but the shard bounds and the query are disjoint). When unspecified, the pre-filter phase is executed if any of these conditions is met:
- The request targets more than 128 shards.
- The request targets one or more read-only index.
- The primary sort of the query targets an indexed field.
-
request_cacheboolean If
true, the caching of search results is enabled for requests wheresizeis0. It defaults to index level settings.-
routingstring Routing A custom value that is used to route operations to a specific shard.
-
scrollstring Duration The period to retain the search context for scrolling. By default, this value cannot exceed
1d(24 hours). You can change this limit by using thesearch.max_keep_alivecluster-level setting.-
search_typeSearchType Indicates how distributed term frequencies are calculated for relevance scoring.
Supported values include:
query_then_fetch: Documents are scored using local term and document frequencies for the shard. This is usually faster but less accurate.dfs_query_then_fetch: Documents are scored using global term and document frequencies across all shards. This is usually slower but more accurate.
-
Values:
query_then_fetchdfs_query_then_fetch -
statsstring Specific
tagof the request for logging and statistical purposes.-
stored_fieldsFields A comma-separated list of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the
_sourceparameter defaults tofalse. You can pass_source: trueto return both source fields and stored fields in the search response.-
suggest_fieldstring Field The field to use for suggestions.
-
suggest_modeSuggestMode · default: missing The suggest mode. This parameter can be used only when the
suggest_fieldandsuggest_textquery string parameters are specified.Supported values include:
missing: Only generate suggestions for terms that are not in the shard.popular: Only suggest terms that occur in more docs on the shard than the original term.always: Suggest any matching suggestions based on terms in the suggest text.
-
Values:
missingpopularalways -
suggest_sizenumber The number of suggestions to return. This parameter can be used only when the
suggest_fieldandsuggest_textquery string parameters are specified.-
suggest_textstring The source text for which the suggestions should be returned. This parameter can be used only when the
suggest_fieldandsuggest_textquery string parameters are specified.-
terminate_afternumber · default: 0 The maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting.
IMPORTANT: Use with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. If set to
0(default), the query does not terminate early.-
timeoutstring Duration The period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. It defaults to no timeout.
-
track_total_hitsboolean | number · default: 10000 The number of hits matching the query to count accurately. If
true, the exact number of hits is returned at the cost of some performance. Iffalse, the response does not include the total number of hits matching the query.-
track_scoresboolean · default: false If
true, the request calculates and returns document scores, even if the scores are not used for sorting.-
typed_keysboolean · default: false If
true, aggregation and suggester names are be prefixed by their respective types in the response.-
rest_total_hits_as_intboolean · default: false Indicates whether
hits.totalshould be rendered as an integer or an object in the rest search response.-
versionboolean · default: false If
true, the request returns the document version as part of a hit.-
_sourceSourceConfigParam · default: true The source fields that are returned for matching documents. These fields are returned in the
hits._sourceproperty of the search response. Valid values are:trueto return the entire document source.falseto not return the document source.<string>to return the source fields that are specified as a comma-separated list that supports wildcard (*) patterns.
-
_source_excludesFields A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in
_source_includesquery parameter. If the_sourceparameter isfalse, this parameter is ignored.-
_source_includesFields A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the
_source_excludesquery parameter. If the_sourceparameter isfalse, this parameter is ignored.-
seq_no_primary_termboolean If
true, the request returns the sequence number and primary term of the last modification of each hit.-
qstring A query in the Lucene query string syntax. Query parameter searches do not support the full Elasticsearch Query DSL but are handy for testing.
IMPORTANT: This parameter overrides the query parameter in the request body. If both parameters are specified, documents matching the query request body parameter are not returned.
-
sizenumber · default: 10 The number of hits to return. By default, you cannot page through more than 10,000 hits using the
fromandsizeparameters. To page through more hits, use thesearch_afterparameter.-
fromnumber · default: 0 The starting document offset, which must be non-negative. By default, you cannot page through more than 10,000 hits using the
fromandsizeparameters. To page through more hits, use thesearch_afterparameter.-
sortstring | string A comma-separated list of
<field>:<direction>pairs.
Request
-
aggregationsmap string to AggregationContainer -
Defines the aggregations that are run as part of the search request.
-
collapseFieldCollapse -
Collapses search results the values of the specified field.
-
fieldstring Fieldrequired -
The field to collapse the result set on
-
inner_hitsoneOf -
The number of inner hits and their sort order
-
namestring Name -
The name for the particular inner hit definition in the response. Useful when a search request contains multiple inner hits.
-
sizenumber · default: 3 -
The maximum number of hits to return per
inner_hits. -
fromnumber · default: 0 -
Inner hit starting document offset.
-
collapseFieldCollapse -
docvalue_fieldsFieldAndFormat -
fieldstring Fieldrequired -
A wildcard pattern. The request returns values for field names matching this pattern.
-
formatstring -
The format in which the values are returned.
-
include_unmappedboolean -
explainboolean -
highlightHighlight -
typeHighlighterType -
Supported values include:
plain: Theplainhighlighter uses the standard Lucene highlighterfvh: The fvh highlighter uses the Lucene Fast Vector highlighter.unified: The unified highlighter uses the Lucene Unified Highlighter.
-
Values:
plainfvhunified -
boundary_charsstring · default: .,!? \t\n -
A string that contains each boundary character.
-
boundary_max_scannumber · default: 20 -
How far to scan for boundary characters.
-
boundary_scannerBoundaryScanner -
Specifies how to break the highlighted fragments: chars, sentence, or word. Only valid for the unified and fvh highlighters. Defaults to
sentencefor theunifiedhighlighter. Defaults tocharsfor thefvhhighlighter.Supported values include:
chars: Use the characters specified byboundary_charsas highlighting boundaries. Theboundary_max_scansetting controls how far to scan for boundary characters. Only valid for thefvhhighlighter.sentence: Break highlighted fragments at the next sentence boundary, as determined by Java’sBreakIterator. You can specify the locale to use withboundary_scanner_locale. When used with theunifiedhighlighter, thesentencescanner splits sentences bigger thanfragment_sizeat the first word boundary next to fragment_size. You can setfragment_sizeto0to never split any sentence.word: Break highlighted fragments at the next word boundary, as determined by Java’sBreakIterator. You can specify the locale to use withboundary_scanner_locale.
-
Values:
charssentenceword -
boundary_scanner_localestring · default: Locale.ROOT -
Controls which locale is used to search for sentence and word boundaries. This parameter takes a form of a language tag, for example:
"en-US","fr-FR","ja-JP". -
force_sourcebooleandeprecated -
fragmenterHighlighterFragmenter · default: span -
Specifies how text should be broken up in highlight snippets:
simpleorspan. Only valid for theplainhighlighter. -
Values:
simplespan -
fragment_sizenumber · default: 100 -
The size of the highlighted fragment in characters.
-
highlight_filterboolean -
highlight_queryQueryContainer -
Highlight matches for a query other than the search query. This is especially useful if you use a rescore query because those are not taken into account by highlighting by default.
-
max_fragment_lengthnumber -
max_analyzed_offsetnumber -
If set to a non-negative value, highlighting stops at this defined maximum limit. The rest of the text is not processed, thus not highlighted and no error is returned The
max_analyzed_offsetquery setting does not override theindex.highlight.max_analyzed_offsetsetting, which prevails when it’s set to lower value than the query setting. -
no_match_sizenumber · default: 0 -
The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight.
-
number_of_fragmentsnumber · default: 5 -
The maximum number of fragments to return. If the number of fragments is set to
0, no fragments are returned. Instead, the entire field contents are highlighted and returned. This can be handy when you need to highlight short texts such as a title or address, but fragmentation is not required. Ifnumber_of_fragmentsis0,fragment_sizeis ignored. -
optionsmap string to object -
orderHighlighterOrder · default: none -
Sorts highlighted fragments by score when set to
score. By default, fragments will be output in the order they appear in the field (order:none). Setting this option toscorewill output the most relevant fragments first. Each highlighter applies its own logic to compute relevancy scores. -
Values:
score -
phrase_limitnumber · default: 256 -
Controls the number of matching phrases in a document that are considered. Prevents the
fvhhighlighter from analyzing too many phrases and consuming too much memory. When usingmatched_fields,phrase_limitphrases per matched field are considered. Raising the limit increases query time and consumes more memory. Only supported by thefvhhighlighter. -
Use in conjunction with
pre_tagsto define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in<em>and</em>tags. -
Use in conjunction with
post_tagsto define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in<em>and</em>tags. -
require_field_matchboolean · default: true -
By default, only fields that contains a query match are highlighted. Set to
falseto highlight all fields. -
Set to
styledto use the built-in tag schema. -
Values:
styled -
encoderHighlighterEncoder -
Values:
defaulthtml -
fieldsmap string to HighlightFieldrequired -
<string>HighlightField -
typeHighlighterType -
Supported values include:
plain: Theplainhighlighter uses the standard Lucene highlighterfvh: The fvh highlighter uses the Lucene Fast Vector highlighter.unified: The unified highlighter uses the Lucene Unified Highlighter.
-
Values:
plainfvhunified -
boundary_charsstring · default: .,!? \t\n -
A string that contains each boundary character.
-
boundary_max_scannumber · default: 20 -
How far to scan for boundary characters.
-
boundary_scannerBoundaryScanner -
Specifies how to break the highlighted fragments: chars, sentence, or word. Only valid for the unified and fvh highlighters. Defaults to
sentencefor theunifiedhighlighter. Defaults tocharsfor thefvhhighlighter.Supported values include:
chars: Use the characters specified byboundary_charsas highlighting boundaries. Theboundary_max_scansetting controls how far to scan for boundary characters. Only valid for thefvhhighlighter.sentence: Break highlighted fragments at the next sentence boundary, as determined by Java’sBreakIterator. You can specify the locale to use withboundary_scanner_locale. When used with theunifiedhighlighter, thesentencescanner splits sentences bigger thanfragment_sizeat the first word boundary next to fragment_size. You can setfragment_sizeto0to never split any sentence.word: Break highlighted fragments at the next word boundary, as determined by Java’sBreakIterator. You can specify the locale to use withboundary_scanner_locale.
-
Values:
charssentenceword -
boundary_scanner_localestring · default: Locale.ROOT -
Controls which locale is used to search for sentence and word boundaries. This parameter takes a form of a language tag, for example:
"en-US","fr-FR","ja-JP". -
force_sourcebooleandeprecated -
fragmenterHighlighterFragmenter · default: span -
Specifies how text should be broken up in highlight snippets:
simpleorspan. Only valid for theplainhighlighter. -
Values:
simplespan -
fragment_sizenumber · default: 100 -
The size of the highlighted fragment in characters.
-
highlight_filterboolean -
highlight_queryQueryContainer -
Highlight matches for a query other than the search query. This is especially useful if you use a rescore query because those are not taken into account by highlighting by default.
-
max_fragment_lengthnumber -
max_analyzed_offsetnumber -
If set to a non-negative value, highlighting stops at this defined maximum limit. The rest of the text is not processed, thus not highlighted and no error is returned The
max_analyzed_offsetquery setting does not override theindex.highlight.max_analyzed_offsetsetting, which prevails when it’s set to lower value than the query setting. -
no_match_sizenumber · default: 0 -
The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight.
-
number_of_fragmentsnumber · default: 5 -
The maximum number of fragments to return. If the number of fragments is set to
0, no fragments are returned. Instead, the entire field contents are highlighted and returned. This can be handy when you need to highlight short texts such as a title or address, but fragmentation is not required. Ifnumber_of_fragmentsis0,fragment_sizeis ignored. -
optionsmap string to object -
orderHighlighterOrder · default: none -
Sorts highlighted fragments by score when set to
score. By default, fragments will be output in the order they appear in the field (order:none). Setting this option toscorewill output the most relevant fragments first. Each highlighter applies its own logic to compute relevancy scores. -
Values:
score -
phrase_limitnumber · default: 256 -
Controls the number of matching phrases in a document that are considered. Prevents the
fvhhighlighter from analyzing too many phrases and consuming too much memory. When usingmatched_fields,phrase_limitphrases per matched field are considered. Raising the limit increases query time and consumes more memory. Only supported by thefvhhighlighter. -
Use in conjunction with
pre_tagsto define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in<em>and</em>tags. -
Use in conjunction with
post_tagsto define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in<em>and</em>tags. -
require_field_matchboolean · default: true -
By default, only fields that contains a query match are highlighted. Set to
falseto highlight all fields. -
Set to
styledto use the built-in tag schema. -
Values:
styled -
fragment_offsetnumber -
matched_fieldsstring Fields -
ignore_unmappedboolean -
script_fieldsmap string to ScriptField -
<string>ScriptField -
scriptstring Scriptrequired -
ignore_failureboolean -
seq_no_primary_termboolean -
fieldsstring Field -
sortSort -
How the inner hits should be sorted per
inner_hits. By default, inner hits are sorted by score. -
_sourceSourceConfig -
stored_fieldsstring Fields -
track_scoresboolean · default: false -
versionboolean -
max_concurrent_group_searchesnumber -
The number of concurrent requests allowed to retrieve the inner_hits per group
-
collapseFieldCollapse -
explainboolean · default: false -
If
true, the request returns detailed information about score computation as part of a hit. -
extmap string to object -
Configuration of search extensions defined by Elasticsearch plugins.
-
fromnumber · default: 0 -
The starting document offset, which must be non-negative. By default, you cannot page through more than 10,000 hits using the
fromandsizeparameters. To page through more hits, use thesearch_afterparameter. -
highlightHighlight -
Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results.
-
track_total_hitsboolean | number · default: 10000 -
Number of hits matching the query to count accurately. If
true, the exact number of hits is returned at the cost of some performance. Iffalse, the response does not include the total number of hits matching the query. -
indices_booststring to number -
Boost the
_scoreof documents from specified indices. The boost value is the factor by which scores are multiplied. A boost value greater than1.0increases the score. A boost value between0and1.0decreases the score. - Reference
-
docvalue_fieldsFieldAndFormat -
An array of wildcard (
*) field patterns. The request returns doc values for field names matching these patterns in thehits.fieldsproperty of the response. - Reference
-
fieldstring Fieldrequired -
A wildcard pattern. The request returns values for field names matching this pattern.
-
formatstring -
The format in which the values are returned.
-
include_unmappedboolean -
knnoneOf -
The approximate kNN search to run.
- Reference
-
fieldstring Fieldrequired -
The name of the vector field to search against
-
query_vectorQueryVector -
The query vector
-
query_vector_builderQueryVectorBuilder -
The query vector builder. You must provide a query_vector_builder or query_vector, but not both.
-
text_embeddingTextEmbedding -
model_idstring -
Model ID is required for all dense_vector fields but may be inferred for semantic_text fields
-
model_textstringrequired -
knumber -
The final number of nearest neighbors to return as top hits
-
num_candidatesnumber -
The number of nearest neighbor candidates to consider per shard
-
boostnumber -
Boost value to apply to kNN scores
-
filteroneOf -
Filters for the kNN search query
-
similaritynumber -
The minimum similarity for a vector to be considered a match
-
inner_hitsInnerHits -
If defined, each search hit will contain inner hits.
-
namestring Name -
The name for the particular inner hit definition in the response. Useful when a search request contains multiple inner hits.
-
sizenumber · default: 3 -
The maximum number of hits to return per
inner_hits. -
fromnumber · default: 0 -
Inner hit starting document offset.
-
collapseFieldCollapse -
fieldstring Fieldrequired -
The field to collapse the result set on
-
inner_hitsoneOf -
The number of inner hits and their sort order
-
max_concurrent_group_searchesnumber -
The number of concurrent requests allowed to retrieve the inner_hits per group
-
collapseFieldCollapse -
docvalue_fieldsFieldAndFormat -
fieldstring Fieldrequired -
A wildcard pattern. The request returns values for field names matching this pattern.
-
formatstring -
The format in which the values are returned.
-
include_unmappedboolean -
explainboolean -
highlightHighlight -
ignore_unmappedboolean -
script_fieldsmap string to ScriptField -
<string>ScriptField -
scriptstring Scriptrequired -
ignore_failureboolean -
seq_no_primary_termboolean -
fieldsstring Field -
sortSort -
How the inner hits should be sorted per
inner_hits. By default, inner hits are sorted by score. -
_sourceSourceConfig -
stored_fieldsstring Fields -
track_scoresboolean · default: false -
versionboolean -
rescore_vectorRescoreVector -
Apply oversampling and rescoring to quantized vectors *
-
oversamplenumberrequired -
Applies the specified oversample factor to k on the approximate kNN search
-
_namestring -
rankRankContainer -
The Reciprocal Rank Fusion (RRF) to use.
-
rrfRrfRank -
The reciprocal rank fusion parameters
-
rank_constantnumber -
How much influence documents in individual result sets per query have over the final ranked result set
-
rank_window_sizenumber -
Size of the individual result sets per query
-
min_scorenumber -
The minimum
_scorefor matching documents. Documents with a lower_scoreare not included in search results and results collected by aggregations. -
post_filterQueryContainer -
Use the
post_filterparameter to filter search results. The search hits are filtered after the aggregations are calculated. A post filter has no impact on the aggregation results. -
profileboolean · default: false -
Set to
trueto return detailed timing information about the execution of individual components in a search request. NOTE: This is a debugging tool and adds significant overhead to search execution. -
queryQueryContainer -
The search definition using the Query DSL.
-
rescoreoneOf -
Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by the
queryandpost_filterphases. -
window_sizenumber -
queryRescoreQuery -
rescore_queryQueryContainerrequired -
The query to use for rescoring. This query is only run on the Top-K results returned by the
queryandpost_filterphases. -
query_weightnumber · default: 1 -
Relative importance of the original query versus the rescore query.
-
rescore_query_weightnumber · default: 1 -
Relative importance of the rescore query versus the original query.
-
score_modeScoreMode · default: total -
Determines how scores are combined.
Supported values include:
avg: Average the original score and the rescore query score.max: Take the max of original score and the rescore query score.min: Take the min of the original score and the rescore query score.multiply: Multiply the original score by the rescore query score. Useful forfunctionquery rescores.total: Add the original score and the rescore query score.
-
Values:
avgmaxminmultiplytotal -
learning_to_rankLearningToRank -
retrieverRetrieverContainer -
A retriever is a specification to describe top documents returned from a search. A retriever replaces other elements of the search API that also return top documents such as
queryandknn. -
standardStandardRetriever -
A retriever that replaces the functionality of a traditional query.
-
filteroneOf -
Query to filter the documents that can match.
-
min_scorenumber -
Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
_namestring -
Retriever name.
-
queryQueryContainer -
Defines a query to retrieve a set of top documents.
-
search_afterSortResults -
Defines a search after object parameter used for pagination.
-
terminate_afternumber -
Maximum number of documents to collect for each shard.
-
sortSort -
A sort object that that specifies the order of matching documents.
-
collapseFieldCollapse -
Collapses the top documents by a specified key into a single top document per key.
-
knnKnnRetriever -
A retriever that replaces the functionality of a knn search.
-
filteroneOf -
Query to filter the documents that can match.
-
min_scorenumber -
Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
_namestring -
Retriever name.
-
fieldstringrequired -
The name of the vector field to search against.
-
query_vectorQueryVector -
Query vector. Must have the same number of dimensions as the vector field you are searching against. You must provide a query_vector_builder or query_vector, but not both.
-
query_vector_builderQueryVectorBuilder -
Defines a model to build a query vector.
-
text_embeddingTextEmbedding -
model_idstring -
Model ID is required for all dense_vector fields but may be inferred for semantic_text fields
-
model_textstringrequired -
knumberrequired -
Number of nearest neighbors to return as top hits.
-
num_candidatesnumber -
Number of nearest neighbor candidates to consider per shard.
-
similaritynumber -
The minimum similarity required for a document to be considered a match.
-
rescore_vectorRescoreVector -
Apply oversampling and rescoring to quantized vectors *
-
oversamplenumberrequired -
Applies the specified oversample factor to k on the approximate kNN search
-
rrfRRFRetriever -
A retriever that produces top documents from reciprocal rank fusion (RRF).
-
filteroneOf -
Query to filter the documents that can match.
-
min_scorenumber -
Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
_namestring -
Retriever name.
-
retrieversRetrieverContainerrequired -
A list of child retrievers to specify which sets of returned top documents will have the RRF formula applied to them.
-
rank_constantnumber -
This value determines how much influence documents in individual result sets per query have over the final ranked result set.
-
rank_window_sizenumber -
This value determines the size of the individual result sets per query.
-
querystring -
fieldsstring -
text_similarity_rerankerTextSimilarityReranker -
A retriever that reranks the top documents based on a reranking model using the InferenceAPI
-
filteroneOf -
Query to filter the documents that can match.
-
min_scorenumber -
Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
_namestring -
Retriever name.
-
retrieverRetrieverContainerrequired -
The nested retriever which will produce the first-level results, that will later be used for reranking.
-
rank_window_sizenumber -
This value determines how many documents we will consider from the nested retriever.
-
inference_idstring -
Unique identifier of the inference endpoint created using the inference API.
-
inference_textstringrequired -
The text snippet used as the basis for similarity comparison
-
fieldstringrequired -
The document field to be used for text similarity comparisons. This field should contain the text that will be evaluated against the inference_text
-
ruleRuleRetriever -
A retriever that replaces the functionality of a rule query.
-
filteroneOf -
Query to filter the documents that can match.
-
min_scorenumber -
Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
_namestring -
Retriever name.
-
ruleset_idsId | Idrequired -
The ruleset IDs containing the rules this retriever is evaluating against.
-
match_criteriaobjectrequired -
The match criteria that will determine if a rule in the provided rulesets should be applied.
-
retrieverRetrieverContainerrequired -
The retriever whose results rules should be applied to.
-
rank_window_sizenumber -
This value determines the size of the individual result set.
-
rescorerRescorerRetriever -
A retriever that re-scores only the results produced by its child retriever.
-
filteroneOf -
Query to filter the documents that can match.
-
min_scorenumber -
Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
_namestring -
Retriever name.
-
retrieverRetrieverContainerrequired -
Inner retriever.
-
rescoreoneOfrequired -
window_sizenumber -
queryRescoreQuery -
rescore_queryQueryContainerrequired -
The query to use for rescoring. This query is only run on the Top-K results returned by the
queryandpost_filterphases. -
query_weightnumber · default: 1 -
Relative importance of the original query versus the rescore query.
-
rescore_query_weightnumber · default: 1 -
Relative importance of the rescore query versus the original query.
-
score_modeScoreMode · default: total -
Determines how scores are combined.
Supported values include:
avg: Average the original score and the rescore query score.max: Take the max of original score and the rescore query score.min: Take the min of the original score and the rescore query score.multiply: Multiply the original score by the rescore query score. Useful forfunctionquery rescores.total: Add the original score and the rescore query score.
-
Values:
avgmaxminmultiplytotal -
learning_to_rankLearningToRank -
linearLinearRetriever -
A retriever that supports the combination of different retrievers through a weighted linear combination.
-
filteroneOf -
Query to filter the documents that can match.
-
min_scorenumber -
Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
_namestring -
Retriever name.
-
retrieversInnerRetriever -
Inner retrievers.
-
retrieverRetrieverContainerrequired -
The nested retriever configuration.
-
weightnumber · default: 1 -
Weight multiplier for this retriever's contribution to the linear combination. Must be non-negative.
-
normalizerScoreNormalizer · default: none -
Score normalizer to apply to this retriever's results before weighting. Falls back to the top-level
normalizeron the linear retriever if unset, then tonone(identity) if neither is set. -
Values:
noneminmaxl2_norm -
rank_window_sizenumber -
querystring -
fieldsstring -
normalizerScoreNormalizer -
Values:
noneminmaxl2_norm -
pinnedPinnedRetriever -
A pinned retriever applies pinned documents to the underlying retriever. This retriever will rewrite to a PinnedQueryBuilder.
-
filteroneOf -
Query to filter the documents that can match.
-
min_scorenumber -
Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
_namestring -
Retriever name.
-
retrieverRetrieverContainerrequired -
Inner retriever.
-
idsstring -
rank_window_sizenumber -
script_fieldsmap string to ScriptField -
Retrieve a script evaluation (based on different fields) for each hit.
-
<string>ScriptField -
scriptstring Scriptrequired -
ignore_failureboolean -
search_afterSortResults -
Used to retrieve the next page of hits using a set of sort values from the previous page.
-
sizenumber · default: 10 -
The number of hits to return, which must not be negative. By default, you cannot page through more than 10,000 hits using the
fromandsizeparameters. To page through more hits, use thesearch_afterproperty. -
sliceSlicedScroll -
Split a scrolled search into multiple slices that can be consumed independently.
-
_sourceSourceConfig -
The source fields that are returned for matching documents. These fields are returned in the
hits._sourceproperty of the search response. If thestored_fieldsproperty is specified, the_sourceproperty defaults tofalse. Otherwise, it defaults totrue. - Reference
-
fieldsFieldAndFormat -
An array of wildcard (
*) field patterns. The request returns values for field names matching these patterns in thehits.fieldsproperty of the response. -
fieldstring Fieldrequired -
A wildcard pattern. The request returns values for field names matching this pattern.
-
formatstring -
The format in which the values are returned.
-
include_unmappedboolean -
suggestSuggester -
Defines a suggester that provides similar looking terms based on a provided text.
-
textstring -
Global suggest text, to avoid repetition when the same text is used in several suggesters
-
terminate_afternumber · default: 0 -
The maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting.
IMPORTANT: Use with caution. Elasticsearch applies this property to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this property for requests that target data streams with backing indices across multiple data tiers.
If set to
0(default), the query does not terminate early. -
timeoutstring -
The period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. Defaults to no timeout.
-
track_scoresboolean · default: false -
If
true, calculate and return document scores, even if the scores are not used for sorting. -
versionboolean · default: false -
If
true, the request returns the document version as part of a hit. -
seq_no_primary_termboolean -
If
true, the request returns sequence number and primary term of the last modification of each hit. - Reference
-
stored_fieldsstring Fields -
A comma-separated list of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the
_sourceproperty defaults tofalse. You can pass_source: trueto return both source fields and stored fields in the search response. - Reference
-
pitPointInTimeReference -
Limit the search to a point in time (PIT). If you provide a PIT, you cannot specify an
<index>in the request path. -
idstring Idrequired -
keep_alivestring Duration -
runtime_mappingsRuntimeFields -
One or more runtime fields in the search request. These fields take precedence over mapped fields with the same name.
- Reference
-
statsstring -
The stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API.
Response
-
tooknumberrequired -
The number of milliseconds it took Elasticsearch to run the request. This value is calculated by measuring the time elapsed between receipt of a request on the coordinating node and the time at which the coordinating node is ready to send the response. It includes:
- Communication time between the coordinating node and data nodes
- Time the request spends in the search thread pool, queued for execution
- Actual run time
It does not include:
- Time needed to send the request to Elasticsearch
- Time needed to serialize the JSON response
- Time needed to send the response to a client
-
timed_outbooleanrequired -
If
true, the request timed out before completion; returned results may be partial or empty. -
_shardsShardStatisticsrequired -
A count of shards used for the request.
-
failednumber uintrequired -
The number of shards the operation or search attempted to run on but failed.
-
successfulnumber uintrequired -
The number of shards the operation or search succeeded on.
-
totalnumber uintrequired -
The number of shards the operation or search will run on overall.
-
failuresShardFailure -
indexstring IndexName -
nodestring -
reasonErrorCauserequired -
typestringrequired -
The type of error
-
reasonstringnullable -
A human-readable explanation of the error, in English.
-
stack_tracestring -
The server stack trace. Present only if the
error_trace=trueparameter was sent with the request. -
caused_byErrorCause -
root_causeErrorCause -
suppressedErrorCause -
shardnumber -
statusstring -
primaryboolean -
skippednumber uint -
hitsHitsMetadatarequired -
The returned documents and metadata.
-
totaloneOf -
Total hit count information, present only if
track_total_hitswasn'tfalsein the search request. -
hitsHitrequired -
_indexstring IndexNamerequired -
_idstring Id -
_scorenumber | stringnullable -
_explanationExplanation -
descriptionstringrequired -
detailsExplanationDetailrequired -
descriptionstringrequired -
detailsExplanationDetail -
valuenumberrequired -
valuenumberrequired -
fieldsmap string to object -
highlightmap string to string -
inner_hitsmap string to InnerHitsResult -
<string>InnerHitsResult -
hitsHitsMetadatarequired -
matched_queriesoneOf -
_ignoredstring -
ignored_field_valuesmap string to FieldValue -
_shardstring -
_nodestring -
_routingstring -
_sourceobject -
_ranknumber -
_seq_nonumber SequenceNumber -
_primary_termnumber -
_versionnumber VersionNumber -
sortSortResults -
max_scorenumber | stringnullable -
aggregationsmap string to Aggregate -
_clustersClusterStatistics -
fieldsmap string to object -
max_scorenumber -
num_reduce_phasesnumber -
profileProfile -
shardsShardProfilerequired -
aggregationsAggregationProfilerequired -
breakdownAggregationBreakdownrequired -
build_aggregationnumberrequired -
build_aggregation_countnumberrequired -
build_leaf_collectornumberrequired -
build_leaf_collector_countnumberrequired -
collectnumberrequired -
collect_countnumberrequired -
initializenumberrequired -
initialize_countnumberrequired -
post_collectionnumber -
post_collection_countnumber -
reducenumberrequired -
reduce_countnumberrequired -
descriptionstringrequired -
time_in_nanosDurationValueUnitNanosrequired -
typestringrequired -
debugAggregationProfileDebug -
collection_strategystring -
total_bucketsnumber -
built_bucketsnumber -
result_strategystring -
has_filterboolean -
delegatestring -
delegate_debugAggregationProfileDebug -
chars_fetchednumber -
extract_countnumber -
extract_nsnumber -
values_fetchednumber -
collect_analyzed_nsnumber -
collect_analyzed_countnumber -
surviving_bucketsnumber -
ordinals_collectors_usednumber -
numeric_collectors_usednumber -
empty_collectors_usednumber -
deferred_aggregatorsstring -
segments_with_deleted_docsnumber -
filtersAggregationProfileDelegateDebugFilter -
results_from_metadatanumber -
querystring -
specialized_forstring -
segments_countednumber -
segments_collectednumber -
map_reducerstring -
brute_force_usednumber -
dynamic_pruning_attemptednumber -
dynamic_pruning_usednumber -
skipped_due_to_no_datanumber -
childrenAggregationProfile -
clusterstringrequired -
dfsDfsProfile -
statisticsDfsStatisticsProfile -
typestringrequired -
descriptionstringrequired -
timestring Duration -
time_in_nanosDurationValueUnitNanosrequired -
breakdownDfsStatisticsBreakdownrequired -
collection_statisticsnumberrequired -
collection_statistics_countnumberrequired -
create_weightnumberrequired -
create_weight_countnumberrequired -
rewritenumberrequired -
rewrite_countnumberrequired -
term_statisticsnumberrequired -
term_statistics_countnumberrequired -
debugmap string to object -
childrenDfsStatisticsProfile -
knnDfsKnnProfile -
vector_operations_countnumber -
queryKnnQueryProfileResultrequired -
typestringrequired -
descriptionstringrequired -
timestring Duration -
time_in_nanosDurationValueUnitNanosrequired -
breakdownKnnQueryProfileBreakdownrequired -
advancenumberrequired -
advance_countnumberrequired -
build_scorernumberrequired -
build_scorer_countnumberrequired -
compute_max_scorenumberrequired -
compute_max_score_countnumberrequired -
count_weightnumberrequired -
count_weight_countnumberrequired -
create_weightnumberrequired -
create_weight_countnumberrequired -
matchnumberrequired -
match_countnumberrequired -
next_docnumberrequired -
next_doc_countnumberrequired -
scorenumberrequired -
score_countnumberrequired -
set_min_competitive_scorenumberrequired -
set_min_competitive_score_countnumberrequired -
shallow_advancenumberrequired -
shallow_advance_countnumberrequired -
debugmap string to object -
childrenKnnQueryProfileResult -
rewrite_timenumberrequired -
fetchFetchProfile -
typestringrequired -
descriptionstringrequired -
time_in_nanosDurationValueUnitNanosrequired -
breakdownFetchProfileBreakdownrequired -
load_sourcenumber -
load_source_countnumber -
load_stored_fieldsnumber -
load_stored_fields_countnumber -
next_readernumber -
next_reader_countnumber -
process_countnumber -
processnumber -
debugFetchProfileDebug -
stored_fieldsstring -
fast_pathnumber -
childrenFetchProfile -
idstringrequired -
indexstring IndexNamerequired -
node_idstringrequired -
searchesSearchProfilerequired -
collectorCollectorrequired -
namestringrequired -
reasonstringrequired -
time_in_nanosDurationValueUnitNanosrequired -
childrenCollector -
queryQueryProfilerequired -
breakdownQueryBreakdownrequired -
advancenumberrequired -
advance_countnumberrequired -
build_scorernumberrequired -
build_scorer_countnumberrequired -
create_weightnumberrequired -
create_weight_countnumberrequired -
matchnumberrequired -
match_countnumberrequired -
shallow_advancenumberrequired -
shallow_advance_countnumberrequired -
next_docnumberrequired -
next_doc_countnumberrequired -
scorenumberrequired -
score_countnumberrequired -
compute_max_scorenumberrequired -
compute_max_score_countnumberrequired -
count_weightnumberrequired -
count_weight_countnumberrequired -
set_min_competitive_scorenumberrequired -
set_min_competitive_score_countnumberrequired -
descriptionstringrequired -
time_in_nanosDurationValueUnitNanosrequired -
typestringrequired -
childrenQueryProfile -
rewrite_timenumberrequired -
shard_idnumberrequired -
pit_idstring Id -
_scroll_idstring ScrollId -
The identifier for the search and its search context. You can use this scroll ID with the scroll API to retrieve the next batch of search results for the request. This property is returned only if the
scrollquery parameter is specified in the request. - Reference
-
suggestmap string to Suggest -
terminated_earlyboolean