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*

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-30 14:06:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-30 14:06:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-03-30 14:06:02       82 阅读
  4. Python语言-面向对象

    2024-03-30 14:06:02       91 阅读

热门阅读

  1. docker centos7离线安装ElasticSearch单机版

    2024-03-30 14:06:02       40 阅读
  2. R语言数据分析基础(一)

    2024-03-30 14:06:02       42 阅读
  3. 【React】React表单组件

    2024-03-30 14:06:02       39 阅读
  4. 【C语言】程序翻译过程

    2024-03-30 14:06:02       43 阅读
  5. sqlmap基础知识

    2024-03-30 14:06:02       36 阅读
  6. Go的数据结构与实现【LinkedList】

    2024-03-30 14:06:02       42 阅读
  7. 手写DNS服务器测速程序(工具分享)

    2024-03-30 14:06:02       57 阅读
  8. test6

    test6

    2024-03-30 14:06:02      46 阅读
  9. 成都某公司笔试题sql

    2024-03-30 14:06:02       46 阅读