elasticsearch 为什么不删除别名(但添加别名可以正常工作)?

oxf4rvwz  于 2023-03-12  发布在  ElasticSearch
关注(0)|答案(1)|浏览(163)

我向ES发送以下请求:

PUT /_alias

{
  "actions": [
    {
      "remove": {
        "index": "iso27001-controls-followup-1678369933360",
        "alias": "iso27001-controls-followup-current"
      }
    },
    {
      "remove": {
        "index": "iso27001-controls-followup-1678452135114",
        "alias": "iso27001-controls-followup-current"
      }
    },
    {
      "add": {
        "index": "iso27001-controls-followup-1678455704228",
        "alias": "iso27001-controls-followup-current"
      }
    }
  ]
}

上面提到的别名确实存在,我希望首先删除所有别名,然后添加一个新别名。

GET /_cat/aliases/iso27001-controls-followup-current?format=json

[
  {
    "alias": "iso27001-controls-followup-current",
    "index": "iso27001-controls-followup-1678452135114",
    "filter": "-",
    "routing.index": "-",
    "routing.search": "-",
    "is_write_index": "-"
  },
  {
    "alias": "iso27001-controls-followup-current",
    "index": "iso27001-controls-followup-1678455704228",
    "filter": "-",
    "routing.index": "-",
    "routing.search": "-",
    "is_write_index": "-"
  },
  {
    "alias": "iso27001-controls-followup-current",
    "index": "iso27001-controls-followup-1678369933360",
    "filter": "-",
    "routing.index": "-",
    "routing.search": "-",
    "is_write_index": "-"
  }
]

已正确创建新别名但未处理remove请求。为什么?

r8uurelv

r8uurelv1#

尾巴;

我认为endpoint_aliases而不是_alias(至少在8.x版本中是这样)。

溶液

此序列在我的设置中表现正确。

PUT index_1
PUT index_2
PUT index_3

POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "index_1",
        "alias": "alias_1"
      }
    },
    {
      "add": {
        "index": "index_2",
        "alias": "alias_2"
      }
    }
  ]
}

GET _cat/aliases/alias*
#alias_1 index_2 - - - -
#alias_2 index_2 - - - -

POST _aliases
{
  "actions": [
    {
      "remove": {
        "index": "index_1",
        "alias": "alias_1"
      }
    },
    {
      "add": {
        "index": "index_3",
        "alias": "alias_3"
      }
    },
    {
      "remove": {
        "index": "index_2",
        "alias": "alias_2"
      }
    }
  ]
}

GET _cat/aliases/alias*
#alias_3 index_3 - - - -

相关问题