【问题标题】:Index Cleanup and Retention Elastic Cloud索引清理和保留 Elastic Cloud
【发布时间】:2019-11-14 15:33:28
【问题描述】:
【问题讨论】:
标签:
elasticsearch
elastic-cloud
【解决方案1】:
我通过使用索引生命周期管理 (ILM) 和索引模板创建翻转来解决这个问题。大部分信息都可以在这里找到:https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html
但它的要点是:
创建 ILM
使用翻转别名创建索引模板:
PUT _template/example-template-name
{
"index_patterns": [
"example-index-*"
],
"settings": {
"index": {
"lifecycle": {
"name": "name-of-lifecycle-created-earlier",
"rollover_alias": "example-index-name"
}
}
}
}
然后创建具有翻转别名别名的第一个索引。我个人使用翻转日期系统,带有 URL 编码:
PUT /%3Cexample-index-name-%7Bnow%2Fd%7D-1%3E
{
"aliases": {
"example-index-name": {
"is_write_index" : true
}
}
}
在此之后只需写入别名,而不是索引本身。当满足 ILM 限制时,它将自动分配正确的索引和翻转。