---
type: api
title: Get legacy index templates
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v9/operation/operation-indices-get-template
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v9/operation/operation-indices-get-template
products:
  - Elasticsearch
---

# Get legacy index templates

deprecated

Authentication: required

## Paths

- `GET` `/_template/{name}`
- `GET` `/_template`

#### Path parameters

- `name` (union string | string[]) — optional, leave it out to use `/_template`
  Comma-separated list of index template names used to limit the request.
Wildcard (`*`) expressions are supported.
To return all index templates, omit this parameter or use a value of `_all` or `*`.

## Description

Get information about one or more index templates.

IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8.

[Learn more about templates](https://www.elastic.co/docs/manage-data/data-store/templates)

## Required authorization

- Cluster privileges: `manage_index_templates`

## Query string parameters

- `flat_settings` (boolean · default: false) — optional
  If `true`, returns settings in flat format.
- `local` (boolean · default: false) — optional — deprecated
  If `true`, the request retrieves information from the local node only.
- `master_timeout` (string · default: 30s) — optional
  Period to wait for a connection to the master node.
If no response is received before the timeout expires, the request fails and returns an error.

## Response

`application/json`

- `<string>` (object)
  - `aliases` (map string to object)
    Map values (object)
    - `filter` ({} Query)
      Query used to limit documents the alias can access.
      See [Query](https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v9/types/_types-query_dsl-querycontainer)
    - `index_routing` (string)
      Value used to route indexing operations to a specific shard.
If specified, this overwrites the `routing` value for indexing operations.
    - `is_hidden` (boolean · default: false)
      If `true`, the alias is hidden.
All indices for the alias must have the same `is_hidden` value.
    - `is_write_index` (boolean · default: false)
      If `true`, the index is the write index for the alias.
    - `routing` (string)
      Value used to route indexing and search operations to a specific shard.
    - `search_routing` (string)
      Value used to route search operations to a specific shard.
If specified, this overwrites the `routing` value for search operations.
  - `index_patterns` (string[])
  - `mappings` (object)
    - `all_field` (object)
      - `analyzer` (string)
      - `enabled` (boolean)
      - `omit_norms` (boolean)
      - `search_analyzer` (string)
      - `similarity` (string)
      - `store` (boolean)
      - `store_term_vector_offsets` (boolean)
      - `store_term_vector_payloads` (boolean)
      - `store_term_vector_positions` (boolean)
      - `store_term_vectors` (boolean)
    - `date_detection` (boolean)
    - `dynamic` (enum)
      Values: `strict`, `runtime`, `true`, `false`
    - `dynamic_date_formats` (string[])
    - `dynamic_templates` (string to object[])
    - `_field_names` (object)
      - `enabled` (boolean)
    - `index_field` (object)
      - `enabled` (boolean)
    - `_meta` (object)
    - `numeric_detection` (boolean)
    - `properties` (map string to oneOf)
    - `_routing` (object)
      - `required` (boolean)
    - `_size` (object)
      - `enabled` (boolean)
    - `_source` (object)
      - `enabled` (boolean)
      - `excludes` (string[])
      - `includes` (string[])
      - `mode` (enum)
        

Supported values include:
  - `disabled`
  - `stored`
  - `columnar_stored`
  - `synthetic`: Instead of storing source documents on disk exactly as you send them,
 Elasticsearch can reconstruct source content on the fly upon retrieval.
        Values: `disabled`, `stored`, `columnar_stored`, `synthetic`
    - `runtime` (map string to object)
      Map values (object)
      - `fields` (map string to object)
        For type `composite`
        Map values (object)
        - `type` (enum)
          Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
      - `fetch_fields` (object[])
        For type `lookup`
        - `field` (string)
        - `format` (string)
      - `format` (string)
        A custom format for `date` type runtime fields.
      - `input_field` (string)
        For type `lookup`
      - `target_field` (string)
        For type `lookup`
      - `target_index` (string)
        For type `lookup`
      - `script` (string)
        Painless script executed at query time.
      - `on_script_error` (enum)
        Values: `fail`, `continue`
      - `type` (enum)
        Field type, which can be: `boolean`, `composite`, `date`, `double`, `geo_point`, `ip`,`keyword`, `long`, or `lookup`.
        Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
    - `enabled` (boolean)
    - `subobjects` (enum)
      Values: `true`, `false`
    - `_data_stream_timestamp` (object)
      - `enabled` (boolean)
  - `order` (number)
  - `settings` (map string to object)
  - `version` (number)
## Code examples

#### Console

```console
GET /_template/.monitoring-*
```

#### JavaScript

```javascript
const response = await client.indices.getTemplate({
  name: ".monitoring-*",
});
```

#### Python

```python
resp = client.indices.get_template(
    name=".monitoring-*",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_template/.monitoring-*" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.indices().getTemplate(g -> g
    .name(".monitoring-*")
);
```

#### C#

```c#
var response = await client.Indices
    .GetTemplateAsync(d1 => d1
        .Name(new[] { ".monitoring-*" })
    );
```

#### PHP

```php
$resp = $client->indices()->getTemplate([
    "name" => ".monitoring-*",
]);
```

#### Ruby

```ruby
response = client.indices.get_template(
  name: ".monitoring-*"
)
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "key": {
    "aliases": {
      "key": {
        "filter": {
          "bool": {
            "boost": 1,
            "_name": "string"
          },
          "boosting": {
            "boost": 1,
            "_name": "string",
            "negative_boost": 0
          },
          "common": {},
          "combined_fields": {
            "boost": 1,
            "_name": "string",
            "query": "string",
            "auto_generate_synonyms_phrase_query": true,
            "operator": "or",
            "zero_terms_query": "none"
          },
          "constant_score": {
            "boost": 1,
            "_name": "string"
          },
          "dense_vector": {
            "boost": 1,
            "_name": "string",
            "quantized": false
          },
          "dis_max": {
            "boost": 1,
            "_name": "string",
            "tie_breaker": 0
          },
          "exists": {
            "boost": 1,
            "_name": "string"
          },
          "function_score": {
            "boost": 1,
            "_name": "string",
            "boost_mode": "multiply",
            "max_boost": 0,
            "min_score": 0,
            "score_mode": "multiply"
          },
          "fuzzy": {},
          "geo_bounding_box": {
            "boost": 1,
            "_name": "string",
            "validation_method": "\u0027strict\u0027",
            "ignore_unmapped": false
          },
          "geo_distance": {
            "boost": 1,
            "_name": "string",
            "distance_type": "\u0027arc\u0027",
            "validation_method": "\u0027strict\u0027",
            "ignore_unmapped": false
          },
          "geo_grid": {},
          "geo_polygon": {
            "boost": 1,
            "_name": "string",
            "validation_method": "\u0027strict\u0027",
            "ignore_unmapped": false
          },
          "geo_shape": {
            "boost": 1,
            "_name": "string",
            "ignore_unmapped": false
          },
          "has_child": {
            "boost": 1,
            "_name": "string",
            "ignore_unmapped": false,
            "max_children": 0,
            "min_children": 0,
            "score_mode": "\u0027none\u0027"
          },
          "has_parent": {
            "boost": 1,
            "_name": "string",
            "ignore_unmapped": false,
            "score": false
          },
          "ids": {
            "boost": 1,
            "_name": "string"
          },
          "intervals": {},
          "knn": {
            "boost": 1,
            "_name": "string",
            "num_candidates": 0,
            "visit_percentage": 0,
            "k": 0,
            "similarity": 0
          },
          "kql": {
            "boost": 1,
            "_name": "string",
            "case_insensitive": false,
            "query": "string"
          },
          "match": {},
          "match_all": {
            "boost": 1,
            "_name": "string"
          },
          "match_bool_prefix": {},
          "match_none": {
            "boost": 1,
            "_name": "string"
          },
          "match_phrase": {},
          "match_phrase_prefix": {},
          "more_like_this": {
            "boost": 1,
            "_name": "string",
            "analyzer": "string",
            "boost_terms": 0,
            "fail_on_unsupported_field": true,
            "include": false,
            "max_doc_freq": 0,
            "max_query_terms": 25,
            "max_word_length": 0,
            "min_doc_freq": 5,
            "min_term_freq": 2,
            "min_word_length": 0,
            "routing": "string",
            "version_type": "\u0027internal\u0027"
          },
          "multi_match": {
            "boost": 1,
            "_name": "string",
            "analyzer": "string",
            "auto_generate_synonyms_phrase_query": true,
            "cutoff_frequency": 0,
            "fuzzy_transpositions": true,
            "lenient": false,
            "max_expansions": 50,
            "operator": "\u0027or\u0027",
            "prefix_length": 0,
            "query": "string",
            "slop": 0,
            "tie_breaker": 0,
            "type": "\u0027best_fields\u0027",
            "zero_terms_query": "\u0027none\u0027"
          },
          "nested": {
            "boost": 1,
            "_name": "string",
            "ignore_unmapped": false,
            "score_mode": "\u0027avg\u0027"
          },
          "parent_id": {
            "boost": 1,
            "_name": "string",
            "ignore_unmapped": false
          }
        }
      }
    }
  }
}
```

