NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Applying a policy to an index template
editApplying a policy to an index template
editThe index.lifecycle.name
setting can be set in an index template so that it
is automatically applied to indexes matching the templates index pattern:
PUT _template/my_template { "index_patterns": ["test-*"], "settings": { "number_of_shards": 1, "number_of_replicas": 1, "index.lifecycle.name": "my_policy", "index.lifecycle.rollover_alias": "test-alias" } }
This template will be applied to all indexes which have a name starting
with |
|
The template will set the policy to be used to |
Now that a policy exists and is used in an index template we can create an initial index which will be managed by our policy:
We can now write data to the test-alias
alias. Because we have a rollover
action defined in our policy, when the index grows larger than 25GB index lifecycle management will
create a new index and roll the alias over to use the new index automatically.