Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why are aliases not removed (but adding them works fine)?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading