---
type: api
title: Simulate an index template
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-indices-simulate-template
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-indices-simulate-template
products:
  - Elasticsearch Serverless
---

# Simulate an index template


Availability:

## Paths

- `POST` `/_index_template/_simulate/{name}`
- `POST` `/_index_template/_simulate`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

- `name` (string Name) — optional, leave it out to use `/_index_template/_simulate`
  Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit
this parameter and specify the template configuration in the request body.

## Description

Get the index configuration that would be applied by a particular index template.

## Required authorization

* Cluster privileges: `manage_index_templates`

## Query String Parameters

- `create` (boolean · default: false)
  If true, the template passed in the body is only used if no existing templates match the same index patterns. If false, the simulation uses the template with the highest priority. Note that the template is not permanently added or updated in either case; it is only used for the simulation.
- `cause` (string · default: false)
  User defined reason for dry-run creating the new template for simulation purposes
- `master_timeout` (string Duration · default: 30s)
  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.
- `include_defaults` (boolean · default: false)
  If true, returns all relevant default configurations for the index template.

## Request Body

`application/json`

- `allow_auto_create` (boolean) — optional
  This setting overrides the value of the `action.auto_create_index` cluster setting.
If set to `true` in a template, then indices can be automatically created using that template even if auto-creation of indices is disabled via `actions.auto_create_index`.
If set to `false`, then indices or data streams matching the template must always be explicitly created, and may never be automatically created.
- `index_patterns` (string Indices) — optional
  Array of wildcard (`*`) expressions used to match the names of data streams and indices during creation.
- `composed_of` ([] string Name) — optional
  An ordered list of component template names.
Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence.
- `template` ({} IndexTemplateMapping) — optional
  Template to be applied.
It may optionally include an `aliases`, `mappings`, or `settings` configuration.
  - `aliases` (map string to Alias) — optional
    Aliases to add.
If the index template includes a `data_stream` object, these are data stream aliases.
Otherwise, these are index aliases.
Data stream aliases ignore the `index_routing`, `routing`, and `search_routing` options.
    Map values ({} Alias)
    - `filter` ({} QueryContainer) — optional
      Query used to limit documents the alias can access.
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/types/_types-query_dsl-querycontainer)
    - `index_routing` (string) — optional
      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) — optional
      If `true`, the alias is hidden.
All indices for the alias must have the same `is_hidden` value.
    - `is_write_index` (boolean · default: false) — optional
      If `true`, the index is the write index for the alias.
    - `routing` (string) — optional
      Value used to route indexing and search operations to a specific shard.
    - `search_routing` (string) — optional
      Value used to route search operations to a specific shard.
If specified, this overwrites the `routing` value for search operations.
  - `mappings` ({} TypeMapping) — optional
    Mapping for fields in the index.
If specified, this mapping can include field names, field data types, and mapping parameters.
    - `all_field` ({} AllField) — optional
      - `analyzer` (string) — required
      - `enabled` (boolean) — required
      - `omit_norms` (boolean) — required
      - `search_analyzer` (string) — required
      - `similarity` (string) — required
      - `store` (boolean) — required
      - `store_term_vector_offsets` (boolean) — required
      - `store_term_vector_payloads` (boolean) — required
      - `store_term_vector_positions` (boolean) — required
      - `store_term_vectors` (boolean) — required
    - `date_detection` (boolean) — optional
    - `dynamic` (enum DynamicMapping) — optional
      Values: `strict`, `runtime`, `true`, `false`
    - `dynamic_date_formats` ([] string) — optional
    - `dynamic_templates` ([] string to DynamicTemplate) — optional
    - `_field_names` ({} FieldNamesField) — optional
      - `enabled` (boolean) — required
    - `index_field` ({} IndexField) — optional
      - `enabled` (boolean) — required
    - `_meta` (Metadata) — optional
    - `numeric_detection` (boolean) — optional
    - `properties` (map string to Property) — optional
    - `_routing` ({} RoutingField) — optional
      - `required` (boolean) — required
    - `_size` ({} SizeField) — optional
      - `enabled` (boolean) — required
    - `_source` ({} SourceField) — optional
      - `enabled` (boolean) — optional
      - `excludes` ([] string) — optional
      - `includes` ([] string) — optional
      - `mode` (enum SourceFieldMode) — optional
        

Supported values include:
  - `disabled`
  - `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`, `synthetic`
    - `runtime` (map string to RuntimeField) — optional
      Map values ({} RuntimeField)
      - `fields` (map string to CompositeSubField) — optional
        For type `composite`
        Map values ({} CompositeSubField)
        - `type` (enum RuntimeFieldType) — required
          Values: `boolean`, `composite`, `date`, `double`, `geo_point`, `geo_shape`, `ip`, `keyword`, `long`, `lookup`
      - `fetch_fields` ([] RuntimeFieldFetchFields) — optional
        For type `lookup`
        - `field` (string Field) — required
        - `format` (string) — optional
      - `format` (string) — optional
        A custom format for `date` type runtime fields.
      - `input_field` (string Field) — optional
        For type `lookup`
      - `target_field` (string Field) — optional
        For type `lookup`
      - `target_index` (string IndexName) — optional
        For type `lookup`
      - `script` (string Script) — optional
        Painless script executed at query time.
      - `on_script_error` (enum OnScriptError) — optional
        Values: `fail`, `continue`
      - `type` (enum RuntimeFieldType) — required
        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) — optional
    - `subobjects` (enum Subobjects) — optional
      Values: `true`, `false`
    - `_data_stream_timestamp` ({} DataStreamTimestamp) — optional
      - `enabled` (boolean) — required
  - `settings` (IndexSettings) — optional
    Configuration options for the index.
  - `lifecycle` ({} DataStreamLifecycle) — optional
    - `data_retention` (string Duration) — optional
      If defined, every document added to this data stream will be stored at least for this time frame.
Any time after this duration the document could be deleted.
When empty, every document in this data stream will be stored indefinitely.
    - `effective_retention` (string Duration) — optional
      The least amount of time data should be kept by elasticsearch.
    - `retention_determined_by` (enum RetentionSource) — optional
      Configuration source that can influence the retention of a data stream.
      Values: `data_stream_configuration`, `default_global_retention`, `max_global_retention`, `default_failures_retention`
    - `downsampling` ([] DownsamplingRound) — optional
      The list of downsampling rounds to execute as part of this downsampling configuration
      - `after` (string Duration) — required
        The duration since rollover when this downsampling round should execute
      - `fixed_interval` (string) — required
        The downsample interval.
    - `downsampling_method` (enum SamplingMethod) — optional
      The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires
`downsampling` to be defined. Defaults to `aggregate`.
      Values: `aggregate`, `last_value`
    - `enabled` (boolean · default: true) — optional
      If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle
that's disabled (enabled: `false`) will have no effect on the data stream.
  - `data_stream_options` (union oneOf) — optional — nullable
    - **DataStreamOptionsTemplate**
      Data stream options template contains the same information as DataStreamOptions but allows them to be set explicitly to null.
      - `failure_store` (union oneOf) — optional — nullable
        - **DataStreamFailureStoreTemplate**
          Template equivalent of DataStreamFailureStore that allows nullable values.
          - `enabled` (union boolean | string · default: true) — optional — nullable
            If defined, it turns the failure store on/off (`true`/`false`) for this data stream. A data stream failure store
that's disabled (enabled: `false`) will redirect no new failed indices to the failure store; however, it will
not remove any existing data from the failure store.
          - `lifecycle` (union oneOf) — optional — nullable
            If defined, it specifies the lifecycle configuration for the failure store of this data stream.
            - **FailureStoreLifecycleTemplate**
              Template equivalent of FailureStoreLifecycle that allows nullable values.
              - `data_retention` (union Duration | string) — optional — nullable
                If defined, every document added to this data stream will be stored at least for this time frame.
Any time after this duration the document could be deleted.
When empty, every document in this data stream will be stored indefinitely.
              - `enabled` (boolean · default: true) — optional
                If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle
that's disabled (enabled: `false`) will have no effect on the data stream.
            - **string**
        - **string**
    - **string**
- `data_stream` ({} DataStreamVisibility) — optional
  If this object is included, the template is used to create data streams and their backing indices.
Supports an empty object.
Data streams require a matching index template with a `data_stream` object.
  - `hidden` (boolean) — optional
  - `allow_custom_routing` (boolean) — optional
  - `failure_store` (boolean) — optional
- `priority` (number) — optional
  Priority to determine index template precedence when a new data stream or index is created.
The index template with the highest priority is chosen.
If no priority is specified the template is treated as though it is of priority 0 (lowest priority).
This number is not automatically generated by Elasticsearch.
- `version` (number VersionNumber) — optional
  Version number used to manage index templates externally.
This number is not automatically generated by Elasticsearch.
- `_meta` (Metadata) — optional
  Optional user metadata about the index template.
May have any contents.
This map is not automatically generated by Elasticsearch.
- `ignore_missing_component_templates` ([] string) — optional
  The configuration option ignore_missing_component_templates can be used when an index template
references a component template that might not exist
- `deprecated` (boolean) — optional
  Marks this index template as deprecated. When creating or updating a non-deprecated index template
that uses deprecated components, Elasticsearch will emit a deprecation warning.

## Response

`application/json`

- `overlapping` ([] Overlapping)
  - `name` (string Name)
  - `index_patterns` ([] string)
- `template` ({} Template)
  - `aliases` (map string to Alias)
    Map values ({} Alias)
    - `filter` ({} QueryContainer)
      Query used to limit documents the alias can access.
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/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.
  - `mappings` ({} TypeMapping)
    Same fields as `mappings` in `template`
  - `settings` (IndexSettings)
## Code Examples

#### Console

```console
POST /_index_template/_simulate
{
  "index_patterns": ["my-index-*"],
  "composed_of": ["ct2"],
  "priority": 10,
  "template": {
    "settings": {
      "index.number_of_replicas": 1
    }
  }
}
```

#### JavaScript

```javascript
const response = await client.indices.simulateTemplate({
  index_patterns: ["my-index-*"],
  composed_of: ["ct2"],
  priority: 10,
  template: {
    settings: {
      "index.number_of_replicas": 1,
    },
  },
});
```

#### Python

```python
resp = client.indices.simulate_template(
    index_patterns=[
        "my-index-*"
    ],
    composed_of=[
        "ct2"
    ],
    priority=10,
    template={
        "settings": {
            "index.number_of_replicas": 1
        }
    },
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_index_template/_simulate" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "index_patterns": [
      "my-index-*"
    ],
    "composed_of": [
      "ct2"
    ],
    "priority": 10,
    "template": {
      "settings": {
        "index.number_of_replicas": 1
      }
    }
  }'
```

#### Java

```java
client.indices().simulateTemplate(s -> s
    .composedOf("ct2")
    .indexPatterns("my-index-*")
    .priority(10L)
    .template(t -> t
        .settings(se -> se
            .otherSettings("index.number_of_replicas", JsonData.fromJson("1"))
        )
    )
);
```

#### C#

```c#
var response = await client.Indices
    .SimulateTemplateAsync(d1 => d1
        .ComposedOf(["ct2"])
        .IndexPatterns(new[] { "my-index-*" })
        .Priority(10L)
        .Template(d2 => d2
            .Settings(d3 => d3
                .OtherSettings(new Dictionary<string, object>()
                {
                    { "index.number_of_replicas", 1 }
                })
            )
        )
    );
```

#### PHP

```php
$resp = $client->indices()->simulateTemplate([
    "body" => [
        "index_patterns" => array(
            "my-index-*",
        ),
        "composed_of" => array(
            "ct2",
        ),
        "priority" => 10,
        "template" => [
            "settings" => [
                "index.number_of_replicas" => 1,
            ],
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.indices.simulate_template(
  body: {
    "index_patterns": [
      "my-index-*"
    ],
    "composed_of": [
      "ct2"
    ],
    "priority": 10,
    "template": {
      "settings": {
        "index.number_of_replicas": 1
      }
    }
  }
)
```

## Response Examples

#### Indices simulate template response example2

A successful response from `POST /_index_template/_simulate` with a template configuration in the request body. The response shows any overlapping templates with a lower priority.

```json
{
  "template" : {
    "settings" : {
      "index" : {
        "number_of_replicas" : "1",
        "routing" : {
          "allocation" : {
            "include" : {
              "_tier_preference" : "data_content"
            }
          }
        }
      }
    },
    "mappings" : {
      "properties" : {
        "@timestamp" : {
          "type" : "date"
        }
      }
    },
    "aliases" : { }
  },
  "overlapping" : [
    {
      "name" : "final-template",
      "index_patterns" : [
        "my-index-*"
      ]
    }
  ]
}
```

