在转换特定别名时,我面临一个奇怪的问题。 错误:
{
"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”:“ twitter”
在检查索引信息时。
是否与上述错误相关?它不应该是twitter。是一个错误吗?
我的重命名索引策略是:
#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"
}
请帮助找出上述错误的原因。另外,我在弹性讨论中也发表了同样的问题,但是似乎在那里需要几天的时间才能找到帮助。所以,在这里发布。预先感谢。
答案 0 :(得分:1)
除了@untergeek的回复。问题的原因如下:
实际上,我今天早上尝试了一下,发现所有新鲜事物之后都提到了相同的@untergeek。
在通过快照和还原(参考:here)重命名索引的过程中,<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth- scroll@15.0.0/dist/smooth-scroll.polyfills.min.js"></script>
<script>
const scroll = new SmoothScroll('a[href*="#"]', {
speed: 800
});
</script>
...
<a href="#1">About</a>
...
...
<section id="1">
This is section about
</section>
...
属性(问题描述中)设置错误,这就是为什么我遇到问题。应该设置为
"provided_name": "twitter"
问题不是索引名称,而是上述属性。
我的情况包括重命名索引,然后滚动。
答案 1 :(得分:0)
我已经回答了here,但请提供我在此处提供的答案以供参考。
滚动索引必须通常以破折号和数字结尾(通常必须使用滚动API调用来解决这个问题)。策展人正在检查与您的过渡别名(在粘贴的块中为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"
}
}
}
}