Query parameters

  • If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.

  • If true, network round-trips are minimized for cross-cluster search requests.

  • expand_wildcardsstring | array[string]

    The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid values are: all, open, closed, hidden, none.

    Values are all, open, closed, hidden, or none.

  • explainboolean

    If true, the response includes additional details about score computation as part of a hit.

  • ignore_throttledboolean Deprecated

    If true, specified concrete, expanded, or aliased indices are not included in the response when throttled.

  • If false, the request returns an error if it targets a missing or closed index.

  • The node or shard the operation should be performed on. It is random by default.

  • profileboolean

    If true, the query execution is profiled.

  • routingstring

    A custom value used to route operations to a specific shard.

  • scrollstring

    Specifies how long a consistent view of the index should be maintained for scrolled search.

    Values are -1 or 0.

  • The type of the search operation.

    Values are query_then_fetch or dfs_query_then_fetch.

  • If true, hits.total is rendered as an integer in the response. If false, it is rendered as an object.

  • typed_keysboolean

    If true, the response prefixes aggregation and suggester names with their respective types.

application/json

BodyRequired

  • explainboolean

    If true, returns detailed information about score calculation as part of each hit. If you specify both this and the explain query parameter, the API uses only the query parameter.

  • idstring
  • paramsobject

    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
  • profileboolean

    If true, the query execution is profiled.

  • sourcestring | object

    One of:

Responses

POST /_search/template
GET my-index/_search/template
{
  "id": "my-search-template",
  "params": {
    "query_string": "hello world",
    "from": 0,
    "size": 10
  }
}
resp = client.search_template(
    index="my-index",
    id="my-search-template",
    params={
        "query_string": "hello world",
        "from": 0,
        "size": 10
    },
)
const response = await client.searchTemplate({
  index: "my-index",
  id: "my-search-template",
  params: {
    query_string: "hello world",
    from: 0,
    size: 10,
  },
});
response = client.search_template(
  index: "my-index",
  body: {
    "id": "my-search-template",
    "params": {
      "query_string": "hello world",
      "from": 0,
      "size": 10
    }
  }
)
$resp = $client->searchTemplate([
    "index" => "my-index",
    "body" => [
        "id" => "my-search-template",
        "params" => [
            "query_string" => "hello world",
            "from" => 0,
            "size" => 10,
        ],
    ],
]);
curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"id":"my-search-template","params":{"query_string":"hello world","from":0,"size":10}}' "$ELASTICSEARCH_URL/my-index/_search/template"
Request example
Run `GET my-index/_search/template` to run a search with a search template.
{
  "id": "my-search-template",
  "params": {
    "query_string": "hello world",
    "from": 0,
    "size": 10
  }
}