Query parameters
-
allow_no_indices
boolean If
false
, the request returns an error if any wildcard expression, index alias, or_all
value 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 withfoo
but no index starts withbar
. -
ccs_minimize_roundtrips
boolean If
true
, network round-trips are minimized for cross-cluster search requests. -
expand_wildcards
string | array[string] 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. Supports comma-separated values, such as
open,hidden
. Valid values are:all
,open
,closed
,hidden
,none
. -
explain
boolean If
true
, the response includes additional details about score computation as part of a hit. -
ignore_throttled
boolean Deprecated If
true
, specified concrete, expanded, or aliased indices are not included in the response when throttled. -
ignore_unavailable
boolean If
false
, the request returns an error if it targets a missing or closed index. -
preference
string The node or shard the operation should be performed on. It is random by default.
-
profile
boolean If
true
, the query execution is profiled. -
routing
string A custom value used to route operations to a specific shard.
-
scroll
string Specifies how long a consistent view of the index should be maintained for scrolled search.
-
search_type
string The type of the search operation.
Values are
query_then_fetch
ordfs_query_then_fetch
. -
rest_total_hits_as_int
boolean If
true
,hits.total
is rendered as an integer in the response. Iffalse
, it is rendered as an object. -
typed_keys
boolean If
true
, the response prefixes aggregation and suggester names with their respective types.
Body
Required
-
explain
boolean If
true
, returns detailed information about score calculation as part of each hit. If you specify both this and theexplain
query parameter, the API uses only the query parameter. -
id
string -
params
object Key-value pairs used to replace Mustache variables in the template. The key is the variable name. The value is the variable value.
Hide params attribute Show params attribute object
-
*
object Additional properties
-
-
profile
boolean If
true
, the query execution is profiled. source
string | object One of: Hide attributes Show attributes
-
aggregations
object Defines the aggregations that are run as part of the search request.
External documentation -
collapse
object External documentation -
explain
boolean If
true
, the request returns detailed information about score computation as part of a hit. -
ext
object Configuration of search extensions defined by Elasticsearch plugins.
Hide ext attribute Show ext attribute object
-
*
object Additional properties
-
-
from
number The starting document offset, which must be non-negative. By default, you cannot page through more than 10,000 hits using the
from
andsize
parameters. To page through more hits, use thesearch_after
parameter. -
highlight
object Hide highlight attributes Show highlight attributes object
-
boundary_chars
string A string that contains each boundary character.
-
boundary_max_scan
number How far to scan for boundary characters.
-
boundary_scanner
string Values are
chars
,sentence
, orword
. -
boundary_scanner_locale
string 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_source
boolean Deprecated -
fragmenter
string Values are
simple
orspan
. -
fragment_size
number The size of the highlighted fragment in characters.
-
highlight_filter
boolean -
highlight_query
object An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
External documentation -
max_fragment_length
number -
max_analyzed_offset
number 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_offset
query setting does not override theindex.highlight.max_analyzed_offset
setting, which prevails when it’s set to lower value than the query setting. -
no_match_size
number The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight.
-
number_of_fragments
number 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_fragments
is0
,fragment_size
is ignored. -
options
object Hide options attribute Show options attribute object
-
*
object Additional properties
-
-
order
string Value is
score
. -
phrase_limit
number Controls the number of matching phrases in a document that are considered. Prevents the
fvh
highlighter from analyzing too many phrases and consuming too much memory. When usingmatched_fields
,phrase_limit
phrases per matched field are considered. Raising the limit increases query time and consumes more memory. Only supported by thefvh
highlighter. -
post_tags
array[string] Use in conjunction with
pre_tags
to define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in<em>
and</em>
tags. -
pre_tags
array[string] Use in conjunction with
post_tags
to define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in<em>
and</em>
tags. -
require_field_match
boolean By default, only fields that contains a query match are highlighted. Set to
false
to highlight all fields. -
tags_schema
string Value is
styled
. -
encoder
string Values are
default
orhtml
. -
fields
object Required
-
track_total_hits
boolean | number Number of hits matching the query to count accurately. If true, the exact number of hits is returned at the cost of some performance. If false, the response does not include the total number of hits matching the query. Defaults to 10,000 hits.
-
indices_boost
array[object] Boost the
_score
of documents from specified indices. The boost value is the factor by which scores are multiplied. A boost value greater than1.0
increases the score. A boost value between0
and1.0
decreases the score.External documentation Hide indices_boost attribute Show indices_boost attribute object
-
*
number Additional properties
-
-
docvalue_fields
array[object] An array of wildcard (
*
) field patterns. The request returns doc values for field names matching these patterns in thehits.fields
property of the response.External documentation Hide docvalue_fields attributes Show docvalue_fields attributes object
-
field
string Required Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
-
format
string The format in which the values are returned.
-
include_unmapped
boolean
-
knn
object | array[object] The approximate kNN search to run.
One of: Hide attributes Show attributes
-
field
string Required Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
-
query_vector
array[number] -
query_vector_builder
object Hide query_vector_builder attribute Show query_vector_builder attribute object
-
text_embedding
object Hide text_embedding attributes Show text_embedding attributes object
-
model_id
string Required -
model_text
string Required
-
-
-
k
number The final number of nearest neighbors to return as top hits
-
num_candidates
number The number of nearest neighbor candidates to consider per shard
-
boost
number Boost value to apply to kNN scores
filter
object | array[object] Filters for the kNN search query
One of: An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
External documentation An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
-
similarity
number The minimum similarity for a vector to be considered a match
-
inner_hits
object Hide inner_hits attributes Show inner_hits attributes object
-
name
string -
size
number The maximum number of hits to return per
inner_hits
. -
from
number Inner hit starting document offset.
-
collapse
object External documentation -
docvalue_fields
array[object] -
explain
boolean -
highlight
object -
ignore_unmapped
boolean -
script_fields
object Hide script_fields attribute Show script_fields attribute object
-
*
object Additional properties
-
-
seq_no_primary_term
boolean -
fields
string | array[string] -
sort
array[string | object] _source
boolean | object Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered.
-
stored_fields
string | array[string] -
track_scores
boolean -
version
boolean
-
-
rescore_vector
object Hide rescore_vector attribute Show rescore_vector attribute object
-
oversample
number Required Applies the specified oversample factor to k on the approximate kNN search
-
External documentation Hide attributes Show attributes object
-
field
string Required Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
-
query_vector
array[number] -
query_vector_builder
object Hide query_vector_builder attribute Show query_vector_builder attribute object
-
text_embedding
object
-
-
k
number The final number of nearest neighbors to return as top hits
-
num_candidates
number The number of nearest neighbor candidates to consider per shard
-
boost
number Boost value to apply to kNN scores
-
similarity
number The minimum similarity for a vector to be considered a match
-
inner_hits
object Hide inner_hits attributes Show inner_hits attributes object
-
name
string -
size
number The maximum number of hits to return per
inner_hits
. -
from
number Inner hit starting document offset.
-
collapse
object -
docvalue_fields
array[object] -
explain
boolean -
ignore_unmapped
boolean -
script_fields
object -
seq_no_primary_term
boolean -
fields
string | array[string] -
stored_fields
string | array[string] -
track_scores
boolean -
version
boolean
-
-
rescore_vector
object Hide rescore_vector attribute Show rescore_vector attribute object
-
oversample
number Required Applies the specified oversample factor to k on the approximate kNN search
-
-
-
min_score
number The minimum
_score
for matching documents. Documents with a lower_score
are not included in search results or results collected by aggregations. -
post_filter
object An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
External documentation -
profile
boolean Set to
true
to 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. -
query
object An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
External documentation rescore
object | array[object] Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by the
query
andpost_filter
phases.One of: Hide attributes Show attributes
-
window_size
number -
query
object Hide query attributes Show query attributes object
-
rescore_query
object Required An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
-
query_weight
number Relative importance of the original query versus the rescore query.
-
rescore_query_weight
number Relative importance of the rescore query versus the original query.
-
score_mode
string Values are
avg
,max
,min
,multiply
, ortotal
.
-
-
learning_to_rank
object
Hide attributes Show attributes object
-
window_size
number -
query
object -
learning_to_rank
object
-
-
retriever
object Hide retriever attributes Show retriever attributes object
-
standard
object Hide standard attributes Show standard attributes object
-
min_score
number Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
query
object An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
External documentation -
search_after
array[number | string | boolean | null] A field value.
-
terminate_after
number Maximum number of documents to collect for each shard.
-
sort
array[string | object] -
collapse
object External documentation
-
knn
object Hide knn attributes Show knn attributes object
-
min_score
number Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
field
string Required The name of the vector field to search against.
-
query_vector
array[number] -
query_vector_builder
object Hide query_vector_builder attribute Show query_vector_builder attribute object
-
text_embedding
object
-
-
k
number Required Number of nearest neighbors to return as top hits.
-
num_candidates
number Required Number of nearest neighbor candidates to consider per shard.
-
similarity
number The minimum similarity required for a document to be considered a match.
-
rescore_vector
object Hide rescore_vector attribute Show rescore_vector attribute object
-
oversample
number Required Applies the specified oversample factor to k on the approximate kNN search
-
-
rrf
object Hide rrf attributes Show rrf attributes object
-
min_score
number Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
retrievers
array[object] Required A list of child retrievers to specify which sets of returned top documents will have the RRF formula applied to them.
-
rank_constant
number This value determines how much influence documents in individual result sets per query have over the final ranked result set.
-
rank_window_size
number This value determines the size of the individual result sets per query.
-
text_similarity_reranker
object Hide text_similarity_reranker attributes Show text_similarity_reranker attributes object
-
min_score
number Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
retriever
object Required -
rank_window_size
number This value determines how many documents we will consider from the nested retriever.
-
inference_id
string Unique identifier of the inference endpoint created using the inference API.
-
inference_text
string The text snippet used as the basis for similarity comparison
-
field
string The document field to be used for text similarity comparisons. This field should contain the text that will be evaluated against the inference_text
-
rule
object Hide rule attributes Show rule attributes object
-
min_score
number Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
-
ruleset_ids
array[string] Required The ruleset IDs containing the rules this retriever is evaluating against.
-
match_criteria
object Required The match criteria that will determine if a rule in the provided rulesets should be applied.
-
retriever
object Required -
rank_window_size
number This value determines the size of the individual result set.
-
-
script_fields
object Retrieve a script evaluation (based on different fields) for each hit.
Hide script_fields attribute Show script_fields attribute object
-
*
object Additional properties Hide * attributes Show * attributes object
-
script
object Required Hide script attributes Show script attributes object
-
id
string -
params
object Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.
Hide params attribute Show params attribute object
-
*
object Additional properties
-
-
options
object Hide options attribute Show options attribute object
-
*
string Additional properties
-
-
ignore_failure
boolean
-
-
-
search_after
array[number | string | boolean | null] A field value.
-
size
number The number of hits to return, which must not be negative. By default, you cannot page through more than 10,000 hits using the
from
andsize
parameters. To page through more hits, use thesearch_after
property. -
slice
object sort
string | object | array[string | object] One of: Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
Hide attributes Show attributes
-
_score
object Hide _score attribute Show _score attribute object
-
order
string Values are
asc
ordesc
.
-
-
_doc
object Hide _doc attribute Show _doc attribute object
-
order
string Values are
asc
ordesc
.
-
-
_geo_distance
object Hide _geo_distance attributes Show _geo_distance attributes object
-
mode
string Values are
min
,max
,sum
,avg
, ormedian
. -
distance_type
string Values are
arc
orplane
. -
ignore_unmapped
boolean -
order
string Values are
asc
ordesc
. -
unit
string Values are
in
,ft
,yd
,mi
,nmi
,km
,m
,cm
, ormm
. -
nested
object
-
-
_script
object
One of: Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
Hide attributes Show attributes
-
_score
object -
_doc
object -
_geo_distance
object -
_script
object
-
-
fields
array[object] An array of wildcard (
*
) field patterns. The request returns values for field names matching these patterns in thehits.fields
property of the response.Hide fields attributes Show fields attributes object
-
field
string Required Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
-
format
string The format in which the values are returned.
-
include_unmapped
boolean
-
-
suggest
object Hide suggest attribute Show suggest attribute object
-
text
string Global suggest text, to avoid repetition when the same text is used in several suggesters
-
-
terminate_after
number 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. -
timeout
string 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_scores
boolean If
true
, calculate and return document scores, even if the scores are not used for sorting. -
version
boolean If
true
, the request returns the document version as part of a hit. -
seq_no_primary_term
boolean If
true
, the request returns sequence number and primary term of the last modification of each hit.External documentation -
stored_fields
string | array[string] -
pit
object Hide pit attributes Show pit attributes object
-
id
string Required -
keep_alive
string A duration. Units can be
nanos
,micros
,ms
(milliseconds),s
(seconds),m
(minutes),h
(hours) andd
(days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
-
-
runtime_mappings
object Hide runtime_mappings attribute Show runtime_mappings attribute object
-
*
object Additional properties Hide * attributes Show * attributes object
-
fields
object For type
composite
-
fetch_fields
array[object] For type
lookup
-
format
string A custom format for
date
type runtime fields. -
input_field
string Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
-
target_field
string Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
-
target_index
string -
script
object Hide script attributes Show script attributes object
-
id
string -
params
object Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.
Hide params attribute Show params attribute object
-
*
object Additional properties
-
-
options
object Hide options attribute Show options attribute object
-
*
string Additional properties
-
-
type
string Required Values are
boolean
,composite
,date
,double
,geo_point
,geo_shape
,ip
,keyword
,long
, orlookup
.
-
-
-
stats
array[string] 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.
-
Responses
-
200 application/json
Hide response attributes Show response attributes object
-
took
number Required -
timed_out
boolean Required -
_shards
object Required Hide _shards attributes Show _shards attributes object
-
failed
number Required -
successful
number Required -
total
number Required -
failures
array[object] Hide failures attributes Show failures attributes object
-
index
string -
node
string -
reason
object Required Hide reason attributes Show reason attributes object
-
type
string Required The type of error
-
reason
string A human-readable explanation of the error, in English.
-
stack_trace
string The server stack trace. Present only if the
error_trace=true
parameter was sent with the request. -
caused_by
object -
root_cause
array[object] -
suppressed
array[object]
-
-
shard
number Required -
status
string
-
-
skipped
number
-
-
hits
object Required Hide hits attributes Show hits attributes object
-
hits
array[object] Required Hide hits attributes Show hits attributes object
-
_index
string Required -
_id
string _score
number | string | null -
_explanation
object Hide _explanation attributes Show _explanation attributes object
-
description
string Required -
details
array[object] Required -
value
number Required
-
-
fields
object Hide fields attribute Show fields attribute object
-
*
object Additional properties
-
-
highlight
object Hide highlight attribute Show highlight attribute object
-
*
array[string] Additional properties
-
-
inner_hits
object matched_queries
array[string] | object -
_nested
object -
_ignored
array[string] -
ignored_field_values
object Hide ignored_field_values attribute Show ignored_field_values attribute object
-
*
array[object] Additional properties
-
-
_shard
string -
_node
string -
_routing
string -
_source
object -
_rank
number -
_seq_no
number -
_primary_term
number -
_version
number -
sort
array[number | string | boolean | null] A field value.
-
max_score
number | string | null
-
aggregations
object -
_clusters
object Hide _clusters attributes Show _clusters attributes object
-
skipped
number Required -
successful
number Required -
total
number Required -
running
number Required -
partial
number Required -
failed
number Required -
details
object Hide details attribute Show details attribute object
-
*
object Additional properties Hide * attributes Show * attributes object
-
status
string Required Values are
running
,successful
,partial
,skipped
, orfailed
. -
indices
string Required -
took
number Time unit for milliseconds
-
timed_out
boolean Required -
_shards
object Hide _shards attributes Show _shards attributes object
-
failed
number Required -
successful
number Required -
total
number Required -
failures
array[object] -
skipped
number
-
-
failures
array[object]
-
-
-
-
fields
object Hide fields attribute Show fields attribute object
-
*
object Additional properties
-
-
max_score
number -
num_reduce_phases
number -
profile
object Hide profile attribute Show profile attribute object
-
shards
array[object] Required Hide shards attributes Show shards attributes object
-
aggregations
array[object] Required Hide aggregations attributes Show aggregations attributes object
-
breakdown
object Required -
description
string Required -
type
string Required -
debug
object -
children
array[object]
-
-
cluster
string Required -
dfs
object Hide dfs attributes Show dfs attributes object
-
statistics
object Hide statistics attributes Show statistics attributes object
-
type
string Required -
description
string Required -
time
string A duration. Units can be
nanos
,micros
,ms
(milliseconds),s
(seconds),m
(minutes),h
(hours) andd
(days). Also accepts "0" without a unit and "-1" to indicate an unspecified value. -
breakdown
object Required -
debug
object -
children
array[object]
-
-
knn
array[object]
-
-
fetch
object Hide fetch attributes Show fetch attributes object
-
type
string Required -
description
string Required -
time_in_nanos
number Time unit for nanoseconds
-
breakdown
object Required Hide breakdown attributes Show breakdown attributes object
-
load_source
number -
load_source_count
number -
load_stored_fields
number -
load_stored_fields_count
number -
next_reader
number -
next_reader_count
number -
process_count
number -
process
number
-
-
debug
object Hide debug attributes Show debug attributes object
-
stored_fields
array[string] -
fast_path
number
-
-
children
array[object]
-
-
id
string Required -
index
string Required -
node_id
string Required -
searches
array[object] Required Hide searches attributes Show searches attributes object
-
collector
array[object] Required -
query
array[object] Required -
rewrite_time
number Required
-
-
shard_id
number Required
-
-
-
pit_id
string -
_scroll_id
string -
suggest
object Hide suggest attribute Show suggest attribute object
-
terminated_early
boolean
-
curl \
--request GET 'http://api.example.com/_search/template' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '"{\n \"id\": \"my-search-template\",\n \"params\": {\n \"query_string\": \"hello world\",\n \"from\": 0,\n \"size\": 10\n }\n}"'
{
"id": "my-search-template",
"params": {
"query_string": "hello world",
"from": 0,
"size": 10
}
}