自学内容网 自学内容网

Elasticsearch rollover API

Rollover API | Elasticsearch Guide [8.13] | Elastic

https://www.cnblogs.com/chong-zuo3322/p/13701411.html

# PUT <my-index-{now/d}-000001>
PUT %3Cmy-index-%7Bnow%2Fd%7D-000001%3E
{
  "aliases": {
    "my-alias": {
      "is_write_index": true
    }
  }
}

如果大家对于上面的字符串 “%3Clogs-%7Bnow%2Fd%7D-1%3E” 比较陌生的话,可以参考网站 URL Encode Online | URLEncoder。实际上它就是字符串 “<logs-{now/d}-1>” 的url编码形式。请注意上面的 is_write_index 必须设置为 true

The following request only rolls over the alias if the current write index meets one or more of the following conditions:

  • The index was created 7 or more days ago.
  • The index contains 1,000 or more documents.
  • The index’s largest primary shard is 50GB or larger.

POST /log_alias/_rollover
{
  "conditions": {
    "max_age": "7d",    时间超过7天
    "max_docs":  "2",   doc条数超过2条
    "max_size": "5gb"   大小超过5G
  }
}

{
  "acknowledged": true,
  "shards_acknowledged": true,
  "old_index": "my-index-2099.05.06-000001",
  "new_index": "my-index-2099.05.07-000002",
  "rolled_over": true,
  "dry_run": false,
  "lazy": false,
  "conditions": {
    "[max_age: 7d]": false,
    "[max_docs: 1000]": true,
    "[max_primary_shard_size: 50gb]": false,
    "[max_primary_shard_docs: 2000]": false
  }
}

向别名中添加数据:

PUT log_alias/doc/1
{
  "message": "a dummy log"
}
PUT log_alias/doc/2
{
  "message": "a dummy log"
}

GET _cat/indices/logs-2020.09.21*


原文地址:https://blog.csdn.net/weixin_39355187/article/details/137152823

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!