1

我在翻转特定别名时遇到了一个奇怪的问题。错误:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "index name [twitter] does not match pattern '^.*-\\d+$'"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "index name [twitter] does not match pattern '^.*-\\d+$'"
  },
  "status": 400
}

我有一个模板如下:

{
     "template": "twitter-*",
     "settings": {
       "number_of_shards": 3
     },
     "mappings" : {
           "user" : {
             "properties" : {
                "name" : { "type" : "text" },
                    "id" : { "type" : "text" }
              }
          }
      }
 }

和别名列表

 GET /_aliases
{
  "twitter": {
    "aliases": {}
  },
  ".kibana": {
    "aliases": {}
  },
  "twitter-2019.06.09-1": {
    "aliases": {
      "twitter-alias": {}
    }
  },
  "twitter123": {
    "aliases": {}
  }
}

我通过 takng 快照和恢复过程从 twitter 索引创建了 twitter-2019.06.09-1。

每当我尝试手动跟踪翻转(我是由策展人设置的)时,我都会遇到上述错误。

#Running manual rollover
POST /twitter-alias/_rollover/
{
  "conditions": {
    "max_age":   "7d",
    "max_docs":  1
  }
}

twitter-2019.06.09-1 有以下 3 条记录:

GET twitter-2019.06.09-1/user/_search?size=0
{
  "took": 44,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 0,
    "hits": [ ]
  }
}

我曾尝试删除 twitter 索引,因为它没有用,但翻转 api 发生了同样的错误。

请帮忙。

更新:

阅读以下帖子后: https ://discuss.elastic.co/t/rollover-failing/153676/5

我更新了模板和索引别名列表,如下所示:

#Creating template for new index creation
PUT _template/template_1
{
  "template": "twitter-*",
  "settings": {
    "number_of_shards": 3
  },
"mappings" : {
        "user" : {
            "properties" : {
                "name" : { "type" : "text" },
                "id" : { "type" : "text" }
            }
        }
    },
    "aliases":
    {
    "search-all":{}
    }
}

和索引:

GET twitter-2019.06.09-1
{
  "twitter-2019.06.09-1": {
    "aliases": {
      "search-all": {},
      "twitter-alias": {}
    },
    "mappings": {
      "user": {
        "properties": {
          "id": {
            "type": "text"
          },
          "name": {
            "type": "text"
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1559904447882",
        "number_of_shards": "1",
        "number_of_replicas": "1",
        "uuid": "DnUZcHiyQIi2ab8XVKKVuA",
        "version": {
          "created": "5060099"
        },
        "provided_name": "twitter"
      }
    }
  }
}

问题仍然退出。

我注意到

“provided_name”:“推特”

在检查索引信息时。

它与发布的上述错误有关吗?它不应该是推特。它是一个错误吗?

我的重命名索引策略是:

#Taking snapshot
PUT /_snapshot/eaa-backup/twitter_snapshot
{
  "indices": "twitter",
  "ignore_unavailable": true,
  "include_global_state": false
}

并恢复:

#Now restore with new name
POST /_snapshot/eaa-backup/twitter_snapshot/_restore
{
 "indices": "twitter",
 "ignore_unavailable": "true",
 "include_global_state": false,
 "rename_pattern": "twitter",
 "rename_replacement": "twitter-2019.06.09-1"
 }

请帮助找出上述错误的原因。此外,我在弹性讨论中发布了相同的问题,但似乎需要几天时间才能在那里找到帮助。所以,在这里发帖。提前致谢。

4

2 回答 2

1

除了@untergeek 的回复。以下是问题的原因:

实际上,我今天早上尝试过,在做所有新鲜事后发现了同样的@untergeek。通过拍摄快照和恢复(参考: here)重命名索引时,似乎不知何故,

"provided_name": "twitter"

属性(问题中的描述)设置错误,这就是我遇到问题的原因。它应该设置为

twitter-2019.06.09-1

问题不在于索引名称,而在于上述属性。

我的方案包括重命名索引然后滚动。

于 2019-06-11T04:58:36.350 回答
0

我已经在这里回答了这个问题,但包括我在那里提供的答案以供参考。

通常,翻转索引必须以破折号和数字结尾(您必须通过翻转 API 调用来绕过这个问题)。Curator 正在检查与您的翻转别名关联的索引(twitter位于粘贴的块中),该索引不以破折号和数字结尾。

我不太确定你做错了什么。这是一个工作示例:

PUT twitter-2019.06.09-1
{
  "aliases": {
    "twitter-alias": {
      "is_write_index": true
    }
  }
}

PUT twitter-alias/_doc/1
{
  "doc1": "dummy_doc1"
}
PUT twitter-alias/_doc/2
{
  "doc2": "dummy_doc2"
}

结果:

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "old_index" : "twitter-2019.06.09-1",
  "new_index" : "twitter-2019.06.09-000002",
  "rolled_over" : true,
  "dry_run" : false,
  "conditions" : {
    "[max_docs: 1]" : true
  }
}

此外:

GET twitter-alias

产量:

{
  "twitter-2019.06.09-000002" : {
    "aliases" : {
      "twitter-alias" : {
        "is_write_index" : true
      }
    },
    "mappings" : {...},
    "settings" : {
      "index" : {
        "creation_date" : "1560216263049",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "kMd6jt_dSWKSCW4ertSuLg",
        "version" : {
          "created" : "7010099"
        },
        "provided_name" : "twitter-2019.06.09-000002"
      }
    }
  },
  "twitter-2019.06.09-1" : {
    "aliases" : {
      "twitter-alias" : {
        "is_write_index" : false
      }
    },
    "mappings" : {...},
    "settings" : {
      "index" : {
        "creation_date" : "1560216199250",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "zjIKove5SXqAXSEfseYpQg",
        "version" : {
          "created" : "7010099"
        },
        "provided_name" : "twitter-2019.06.09-1"
      }
    }
  }
}
于 2019-06-11T01:30:42.930 回答