AWS Elasticsearch OpenDistro - 未触发滚动索引

问题描述

我已经使用 AWS Elasticsearch service v7.10 设置了一个 1 节点集群,并且我已经按照这个 OpenDistro guides 创建了简单的索引翻转策略,但是即使我等了几个小时,该策略也根本没有触发.以下是我的 ISM 政策:

PUT _opendistro/_ism/policies/book_rollover_policy
{
    "policy": {
        "policy_id": "book_rollover_policy","description": "Book rollover policy.","default_state": "hot","states": [
            {
                "name": "hot","actions": [
                    {
                        "replica_count": {
                            "number_of_replicas": 0
                        },"rollover": {
                            "min_index_age": "3m"
                        }
                    }
                ],"transitions": []                
            }            
        ],"ism_template": {
            "index_patterns": [
                "book-*"
            ],"priority": 100
        }
    }
}

这是带有翻转别名的模板:

PUT _template/book_ism_rollover
{
  "index_patterns": [
    "book-*"
  ],"settings": {
    "index": {
      "number_of_shards": 1,"number_of_replicas": 0,"opendistro": {
        "index_state_management": {
          "rollover_alias": "book"
        }
      },"analysis": {}
    }
  },"mappings": {
    "properties": {
      "author": {
        "type": "text"
      },"isbn": {
        "type": "text"
      },"price": {
        "type": "float"
      },"publishedDate": {
        "type": "date"
      },"publisher": {
        "type": "text"
      },"title": {
        "type": "text"
      }
    }
  }
}

然后我用别名创建了初始翻转索引:

PUT book-000001
{
  "aliases": {
    "book": {
      "is_write_index": true
    }
  }
}

然后我开始索引一些文档,如下所示:

#Book 1
POST book/_doc
{
  "isbn": "f2338e3e-fabf-45bb-aa6e-5f8cb6f259c1","author": "Jon Skeet","title": "C# in depth","publiser": "Manning Publications","publishedDate": "2008-01-21","price": 29.99
}
#Book 2
POST book/_doc
{
  "isbn": "30e57ff1-98f9-405b-aede-5df460455a5d","author": "Joseph Albahari","title": "C# 9.0 in the nutshell","publiser": "O'Reilley","publishedDate": "2018-03-01","price": 70.99
}
#Book 3
POST book/_doc
{
  "isbn": "14fa6134-f9e4-4525-9d28-f3def875c35c","author": "Mark Lutz","title": "Learning Python","publishedDate": "2010-12-01","price": 30.99
}

根据上述策略,我预计 3 分钟后会创建一个新索引,但什么也没发生。我还尝试了 min_sizemin_doc_count 等不同的翻转操作,但仍然没有运气。我错过了什么吗?谢谢。

解决方法

我终于想出了以下更改,不确定我是否必须拥有全部或其中的几个。

  1. 我创建了一个 2 节点集群而不是 1 节点集群,并将 Elasticsearch 版本从 7.10 降级到 7.9
  2. 我运行了这个请求PUT /_cluster/settings { "persistent": { "opendistro.index_state_management.enabled": true } }
  3. 最后,从 this 开始,我不得不等待 30-48 分钟才能看到新索引被翻转。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...