Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›REST APIs ›Search APIs

Render search template API

New API reference

For the most up-to-date API details, refer to Search APIs.

Renders a search template as a search request body.

resp = client.render_search_template(
    id="my-search-template",
    params={
        "query_string": "hello world",
        "from": 20,
        "size": 10
    },
)
print(resp)
response = client.render_search_template(
  body: {
    id: 'my-search-template',
    params: {
      query_string: 'hello world',
      from: 20,
      size: 10
    }
  }
)
puts response
const response = await client.renderSearchTemplate({
  id: "my-search-template",
  params: {
    query_string: "hello world",
    from: 20,
    size: 10,
  },
});
console.log(response);
POST _render/template
{
  "id": "my-search-template",
  "params": {
    "query_string": "hello world",
    "from": 20,
    "size": 10
  }
}

Request

GET _render/template

GET _render/template/<template-id>

POST _render/template

POST _render/template/<template-id>

Prerequisites

  • If the Elasticsearch security features are enabled, you must have the read index privilege for at least one index pattern.

Path parameters

<template-id>
(Required*, string) ID of the search template to render. If no source is specified, this or the id request body parameter is required.

Request body

id
(Required*, string) 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>.
params
(Optional, object) Key-value pairs used to replace Mustache variables in the template. The key is the variable name. The value is the variable value.
source
(Required*, object) An inline search template. 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.

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/render-search-template-api.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API