Render a search template Generally available

POST /_render/template/{id}

Render a search template as a search request body.

Required authorization

  • Index privileges: read

Path parameters

  • id string Required

    The ID of the search template to render. If no source is specified, this or the id request body parameter is required.

application/json

Body

  • id string
  • file string
  • params object

    Key-value pairs used to replace Mustache variables in the template. The key is the variable name. The value is the variable value.

    Hide params attribute Show params attribute object
    • * object Additional properties
  • source string | object

    One of:

Responses

  • 200 application/json
    Hide response attribute Show response attribute object
    • template_output object Required
      Hide template_output attribute Show template_output attribute object
      • * object Additional properties
POST /_render/template/{id}
POST _render/template { "id": "my-search-template", "params": { "query_string": "hello world", "from": 20, "size": 10 } }
resp = client.render_search_template( id="my-search-template", params={ "query_string": "hello world", "from": 20, "size": 10 }, )
const response = await client.renderSearchTemplate({ id: "my-search-template", params: { query_string: "hello world", from: 20, size: 10, }, });
response = client.render_search_template( body: { "id": "my-search-template", "params": { "query_string": "hello world", "from": 20, "size": 10 } } )
$resp = $client->renderSearchTemplate([ "body" => [ "id" => "my-search-template", "params" => [ "query_string" => "hello world", "from" => 20, "size" => 10, ], ], ]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"id":"my-search-template","params":{"query_string":"hello world","from":20,"size":10}}' "$ELASTICSEARCH_URL/_render/template"
Request example
Run `POST _render/template`
{ "id": "my-search-template", "params": { "query_string": "hello world", "from": 20, "size": 10 } }