Run a search with a search template
Added in 2.0.0
Path parameters
-
index
string | array[string] Required A comma-separated list of data streams, indices, and aliases to search. It supports wildcards (
*
).
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. -
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.
-
profile
boolean If
true
, the query execution is profiled. source
string | object
curl \
--request GET 'http://api.example.com/{index}/_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
}
}