Simulate index API
Returns the index configuration that would be applied to the specified index from an existing index template.
resp = client.indices.simulate_index_template(
name="my-index-000001",
)
print(resp) const response = await client.indices.simulateIndexTemplate({
name: "my-index-000001",
});
console.log(response); POST /_index_template/_simulate_index/my-index-000001
Request
POST /_index_template/_simulate_index/<index>
Prerequisites
- If the Elasticsearch security features are enabled, you must have the
manage_index_templatesormanagecluster privilege to use this API.
Path parameters
-
<index> - (Required, string) Name of the index to simulate.
Query parameters
-
master_timeout - (Optional, time units) Period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. Defaults to
30s. Can also be set to-1to indicate that the request should never timeout. -
include_defaults - (Optional, Boolean) Functionality in [preview] This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. . If
true, return all default settings in the response. Defaults tofalse.
Response body
-
overlapping -
(array) Any templates that also matched the index but were superseded by a higher-priority template. Response includes an empty array if there are no overlapping templates.
Properties of
overlapping-
name - (string) Name of the superseded template.
-
index_patterns - (array) Index patterns that the superseded template applies to.
-
-
template -
(object) The settings, mappings, and aliases that would be applied to the index.
Properties of
template-
aliases -
(object) Aliases for the index. If no aliases apply, the response returns an empty
aliasesobject.-
<alias> -
(object) The key is the alias name. The object body contains options for the alias.
Properties of
<alias>-
filter - (Query DSL object) Query used to limit documents the alias can access.
-
index_routing - (string) Value used to route indexing operations to a specific shard. This overwrites the
routingvalue for indexing operations. -
is_hidden - (Boolean) If
true, the alias is hidden. -
is_write_index - (Boolean) 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. This overwrites the
routingvalue for search operations.
-
-
-
mappings -
(Optional, mapping object) Mapping for fields in the index. If specified, this mapping can include:
- Field names
- Field data types
- Mapping parameters
See Mapping.
Omitted from the response if no mappings would be applied.
-
settings -
(Optional, index setting object) Configuration options for the index. See Index settings.
Response includes an empty object if no settings would be applied.
-
Examples
The following example shows the configuration that would be applied to my-index-000001 by an existing template.
resp = client.cluster.put_component_template(
name="ct1",
template={
"settings": {
"index.number_of_shards": 2
}
},
)
print(resp)
resp1 = client.cluster.put_component_template(
name="ct2",
template={
"settings": {
"index.number_of_replicas": 0
},
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
}
}
}
},
)
print(resp1)
resp2 = client.indices.put_index_template(
name="final-template",
index_patterns=[
"my-index-*"
],
composed_of=[
"ct1",
"ct2"
],
priority=5,
)
print(resp2)
resp3 = client.indices.simulate_index_template(
name="my-index-000001",
)
print(resp3) response = client.cluster.put_component_template(
name: 'ct1',
body: {
template: {
settings: {
'index.number_of_shards' => 2
}
}
}
)
puts response
response = client.cluster.put_component_template(
name: 'ct2',
body: {
template: {
settings: {
'index.number_of_replicas' => 0
},
mappings: {
properties: {
"@timestamp": {
type: 'date'
}
}
}
}
}
)
puts response
response = client.indices.put_index_template(
name: 'final-template',
body: {
index_patterns: [
'my-index-*'
],
composed_of: [
'ct1',
'ct2'
],
priority: 5
}
)
puts response const response = await client.cluster.putComponentTemplate({
name: "ct1",
template: {
settings: {
"index.number_of_shards": 2,
},
},
});
console.log(response);
const response1 = await client.cluster.putComponentTemplate({
name: "ct2",
template: {
settings: {
"index.number_of_replicas": 0,
},
mappings: {
properties: {
"@timestamp": {
type: "date",
},
},
},
},
});
console.log(response1);
const response2 = await client.indices.putIndexTemplate({
name: "final-template",
index_patterns: ["my-index-*"],
composed_of: ["ct1", "ct2"],
priority: 5,
});
console.log(response2);
const response3 = await client.indices.simulateIndexTemplate({
name: "my-index-000001",
});
console.log(response3); PUT /_component_template/ct1
{
"template": {
"settings": {
"index.number_of_shards": 2
}
}
}
PUT /_component_template/ct2
{
"template": {
"settings": {
"index.number_of_replicas": 0
},
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
}
}
}
}
}
PUT /_index_template/final-template
{
"index_patterns": ["my-index-*"],
"composed_of": ["ct1", "ct2"],
"priority": 5
}
POST /_index_template/_simulate_index/my-index-000001 | Create a component template ( | |
| Create a second component template ( | |
| Create an index template ( | |
| Show the configuration that would be applied to |
The response shows the index settings, mappings, and aliases applied by the final-template:
{
"template" : {
"settings" : {
"index" : {
"number_of_shards" : "2",
"number_of_replicas" : "0",
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
}
}
},
"mappings" : {
"properties" : {
"@timestamp" : {
"type" : "date"
}
}
},
"aliases" : { }
},
"overlapping" : [
{
"name" : "template_1",
"index_patterns" : [
"my-index-*"
]
}
]
}
© 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/indices-simulate-index.html