0

I send the following request to 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"
      }
    }
  ]
}

The aliases mentioned do exist and I expected all of the aliases to first be removed, and then a new one added. What I get instead is

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": "-"
  }
]

A new alias was created correctly but the remove requests were not processed. Why?

Paulo
  • 8,690
  • 5
  • 20
  • 34
WoJ
  • 27,165
  • 48
  • 180
  • 345

1 Answers1

1

Tldr;

I believe the endpoint is _aliases not _alias. (at least in version 8.x)

Solution

This sequence behave correctly on my setup.

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 - - - -

Paulo
  • 8,690
  • 5
  • 20
  • 34
  • 1
    You are absolutely right - I just realized that when reading the docs again. Also, it is a `POST`, not a `PUT` – WoJ Mar 10 '23 at 14:33