We have created ILM (index lifecycle management) policies, to automate index rollover using a matching index template and a bootstrap index to enable write index with an alias.
Please find the below API code:
Polices
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_size": "50mb",
"max_primary_shard_size": "50mb",
"max_age": "30m"
},
"set_priority": {
"priority": 200
}
}
},
"cold": {
"min_age": "5m",
"actions": {
"searchable_snapshot": {
"snapshot_repository": "found-snapshots",
"force_merge_index": true
},
"set_priority": {
"priority": 0
}
}
},
"frozen": {
"min_age": "10m",
"actions": {
"searchable_snapshot": {
"snapshot_repository": "found-snapshots",
"force_merge_index": true
}
}
},
"delete": {
"min_age": "1h",
"actions": {
"delete": {
"delete_searchable_snapshot": true
}
}
}
}
}
}
Template
PUT _index_template/sree
{
"index_patterns":["sree-*"],
"template":{
"settings":{
"number_of_shards":1,
"number_of_replicas":1,
"index.lifecycle.name":"sree",
"index.lifecycle.rollover_alias":"sree"
}
}
}
Bootstrap Index:
PUT sree-000001
{
"aliases":{
"sree":{
"is_write_index":true
}
}
}
Note: I'm using logstash to send data to elastic search by using the elasticsearch output plugin.
Here is the output plugin code:
output {
elasticsearch {
hosts => "https:xyz:9243"
user => "elastic"
password => "xyz"
index => "sree-"
ilm_enabled => true
}
}
For the above scenario, I'm successfully creating index and index-alias, indexes are moving to next nodes like cold/frozen but data is not shifting/migrating.