Query parameters
- ccs_minimize_roundtrips
boolean If
true
, network round-trips are minimized for cross-cluster search requests. - max_concurrent_searches
number The maximum number of concurrent searches the API can run.
- 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
, the response returnshits.total
as an integer. Iffalse
, it returnshits.total
as an object. - typed_keys
boolean If
true
, the response prefixes aggregation and suggester names with their respective types.
Bodyobject Required
POST /_msearch/template
Console
GET my-index/_msearch/template
{ }
{ "id": "my-search-template", "params": { "query_string": "hello world", "from": 0, "size": 10 }}
{ }
{ "id": "my-other-search-template", "params": { "query_type": "match_all" }}
resp = client.msearch_template(
index="my-index",
search_templates=[
{},
{
"id": "my-search-template",
"params": {
"query_string": "hello world",
"from": 0,
"size": 10
}
},
{},
{
"id": "my-other-search-template",
"params": {
"query_type": "match_all"
}
}
],
)
const response = await client.msearchTemplate({
index: "my-index",
search_templates: [
{},
{
id: "my-search-template",
params: {
query_string: "hello world",
from: 0,
size: 10,
},
},
{},
{
id: "my-other-search-template",
params: {
query_type: "match_all",
},
},
],
});
response = client.msearch_template(
index: "my-index",
body: [
{},
{
"id": "my-search-template",
"params": {
"query_string": "hello world",
"from": 0,
"size": 10
}
},
{},
{
"id": "my-other-search-template",
"params": {
"query_type": "match_all"
}
}
]
)
$resp = $client->msearchTemplate([
"index" => "my-index",
"body" => array(
new ArrayObject([]),
[
"id" => "my-search-template",
"params" => [
"query_string" => "hello world",
"from" => 0,
"size" => 10,
],
],
new ArrayObject([]),
[
"id" => "my-other-search-template",
"params" => [
"query_type" => "match_all",
],
],
),
]);
curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '[{},{"id":"my-search-template","params":{"query_string":"hello world","from":0,"size":10}},{},{"id":"my-other-search-template","params":{"query_type":"match_all"}}]' "$ELASTICSEARCH_URL/my-index/_msearch/template"
Request example
Run `GET my-index/_msearch/template` to run multiple templated searches.
{ }
{ "id": "my-search-template", "params": { "query_string": "hello world", "from": 0, "size": 10 }}
{ }
{ "id": "my-other-search-template", "params": { "query_type": "match_all" }}