Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you need to delete Elasticsearch aliases?

Can't seem to find a simple yes or no answer to this question.

When you have an index with one or more aliases can you just delete the index without any negative side effects? Will deleting the index also delete the aliases? Should you remove all aliases first before deleting an index?

What is considered best practice?

like image 384
wxkevin Avatar asked Dec 29 '16 15:12

wxkevin


1 Answers

A simple test provides the answer.

First create an index:

PUT my_index

Then create an alias:

POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "my_index",
        "alias": "alias1"
      }
    }
  ]
}

Verify the alias exists:

GET _aliases  # should return the alias named alias1
GET alias1    # should return documents from my_index

Delete the index:

DELETE my_index

Check that the alias is gone too

GET _aliases  # should be empty
GET alias1    # should return "no such index"

To sum it up, no you don't need to delete aliases before/after deleting an index. Simply deleting the index will take care of deleting the orphan alias as well.

like image 78
Val Avatar answered Oct 11 '22 08:10

Val