javaelasticsearchelasticsearch-jest

Add alias to index and remove index using JEST API in Java


I'm using jest api for connect to elastic Search I'm wonder if there is a way in Jest to add alias to index with existing index name and delete the index in same operation. like this, but via Jest api:

POST /_aliases
{
    "actions" : [
        { "add":  { "index": "new_index", "alias": "index_1" } },
        { "remove_index": { "index": "index_1" } }  
    ]
}

Solution

  • Looks like there is no API in JEST to do this in the same API, but you can use two different API, one to add an alias and another to remove an alias.

    Please have a source code of alias mapping(abstract class) which is implemented by Add alias mapping and remove alias mapping classes.

    As mentioned by @Val, it's been dormant() and doesn't support the latest versions of elasticsearch(not greater than 6 which is the end of life as well), so better to migrate to the official Java client if you can.