Replace Index With Alias on ElasticSearch




Copy the Index to a new index,
curl -X POST "https://localhost:9200/_reindex" -H 'Content-Type: application/json' -k -u username:password -d'
{
  "source": {
    "index": "old-index"
  },
  "dest": {
    "index": "new-index"
  }
}
'
Delete the old Index,

curl -X DELETE "https://localhost:9200/index-name" -k -u username:password

Add alias,
curl -X POST "https://localhost:9200/_aliases" -H 'Content-Type: application/json' -k -u user:password -d'
{
    "actions" : [
        { "add" : { "index" : "index-name", "alias" : "alias-name" } }
    ]
}
'

Show alias
curl -X GET "https://localhost:9200/_alias/fla*" -k -u username:password

Comments