Path parameters
-
The ID of the search template to render. If no
source
is specified, this or theid
request body parameter is required.
Body
-
The ID of the search template to render. If no
source
is specified, this or the<template-id>
request path parameter is required. If you specify both this parameter and the<template-id>
parameter, the API uses only<template-id>
. -
Key-value pairs used to replace Mustache variables in the template. The key is the variable name. The value is the variable value.
source
string | object An inline search template. It supports the same parameters as the search API's request body. These parameters also support Mustache variables. If no
id
or<templated-id>
is specified, this parameter is required.
POST /_render/template/{id}
Console
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"
client.renderSearchTemplate(r -> r .id("my-search-template") .params(Map.of("size", JsonData.fromJson("10"),"from", JsonData.fromJson("20"),"query_string", JsonData.fromJson("\"hello world\""))) );
Request example
Run `POST _render/template`
{ "id": "my-search-template", "params": { "query_string": "hello world", "from": 20, "size": 10 } }