Run multiple templated searches Added in 5.0.0
Run multiple templated searches with a single request.
If you are providing a text file or text input to curl
, use the --data-binary
flag instead of -d
to preserve newlines.
For example:
$ cat requests
{ "index": "my-index" }
{ "id": "my-search-template", "params": { "query_string": "hello world", "from": 0, "size": 10 }}
{ "index": "my-other-index" }
{ "id": "my-other-search-template", "params": { "query_type": "match_all" }}
$ curl -H "Content-Type: application/x-ndjson" -XGET localhost:9200/_msearch/template --data-binary "@requests"; echo
Path parameters
-
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*
.
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.
Body object Required
-
allow_no_indices boolean
-
expand_wildcards string | array[string]
-
index string | array[string]
-
preference string
-
request_cache boolean
-
routing string
-
search_type string
Values are
query_then_fetch
ordfs_query_then_fetch
. -
ccs_minimize_roundtrips boolean
-
allow_partial_search_results boolean
-
ignore_throttled boolean
curl \
--request GET http://api.example.com/{index}/_msearch/template \
--header "Content-Type: application/json" \
--data '"{ }\n{ \"id\": \"my-search-template\", \"params\": { \"query_string\": \"hello world\", \"from\": 0, \"size\": 10 }}\n{ }\n{ \"id\": \"my-other-search-template\", \"params\": { \"query_type\": \"match_all\" }}"'
{ }
{ "id": "my-search-template", "params": { "query_string": "hello world", "from": 0, "size": 10 }}
{ }
{ "id": "my-other-search-template", "params": { "query_type": "match_all" }}