Multi search template API
editMulti search template API
editAllows to execute several search template requests.
Request
editGET _msearch/template
Prerequisites
edit-
If the Elasticsearch security features are enabled, you must have the
read
index privilege for the target data stream, index, or index alias. For cross-cluster search, see Cross cluster search and security.
Description
editAllows to execute several search template requests within the same API using the
_msearch/template
endpoint.
The format of the request is similar to the Multi Search API format:
header\n body\n header\n body\n
The header part supports the same index
, search_type
, preference
, and
routing
options as the Multi Search API.
The body includes a search template body request and supports inline, stored and file templates.
Examples
edit$ cat requests {"index": "test"} {"source": {"query": {"match": {"user" : "{{username}}" }}}, "params": {"username": "john"}} {"source": {"query": {"{{query_type}}": {"name": "{{name}}" }}}, "params": {"query_type": "match_phrase_prefix", "name": "Smith"}} {"index": "_all"} {"id": "template_1", "params": {"query_string": "search for these words" }} $ curl -H "Content-Type: application/x-ndjson" -XGET localhost:9200/_msearch/template --data-binary "@requests"; echo
The response returns a responses
array, which includes the search template
response for each search template request matching its order in the original
multi search template request. If there was a complete failure for that specific
search template request, an object with error
message will be returned in
place of the actual search response.