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
Required authorization
- Index privileges:
read
Query parameters
-
If
true, network round-trips are minimized for cross-cluster search requests. -
The maximum number of concurrent searches the API can run.
-
The type of the search operation.
Values are
query_then_fetchordfs_query_then_fetch. -
If
true, the response returnshits.totalas an integer. Iffalse, it returnshits.totalas an object. -
If
true, the response prefixes aggregation and suggester names with their respective types.
GET
/_msearch/template
curl \
--request GET 'http://api.example.com/_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\" }}"'
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" }}