Multi Search Template

Allows to execute several search template requests.

Request

GET _msearch/template

Description

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:

  1. header\n
  2. body\n
  3. header\n
  4. 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

  1. $ cat requests
  2. {"index": "test"}
  3. {"source": {"query": {"match": {"user" : "{{username}}" }}}, "params": {"username": "john"}}
  4. {"source": {"query": {"{{query_type}}": {"name": "{{name}}" }}}, "params": {"query_type": "match_phrase_prefix", "name": "Smith"}}
  5. {"index": "_all"}
  6. {"id": "template_1", "params": {"query_string": "search for these words" }}
  7. $ curl -H "Content-Type: application/x-ndjson" -XGET localhost:9200/_msearch/template --data-binary "@requests"; echo

Inline search template request

Search template request based on a stored template

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.