本地英文版地址: ../en/multi-search-template.html
Multi Search Templateedit
Allows to execute several search template requests.
Requestedit
GET _msearch/template
Descriptionedit
Allows 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.
Examplesedit
$ 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.