Search code examples
elasticsearchelasticsearch-jest

How to execute RemoveAliasMapping in ElasticSearch using JEST


I am trying to remove an alias mapping for an index in ES using jest.

Here is what I have tried :

// create Jest Client.

JestClient client = factory.getObject();

// create RemoveAliasMapping Object.

RemoveAliasMapping removeAliasMapping = new RemoveAliasMapping.Builder("oldIndex", "alias").build();

After creating the removeAliasMapping object, I couldn't find a way to execute it.

If I use the api : client.execute(removeAliasMapping), it says : The method execute(Action<T>) in the type JestClient is not applicable for the arguments (RemoveAliasMapping)

Also, I couldn't find any other api exposed to execute AliasMapping.

Can anyone help me out with this here? If possible, please put an example too.


Solution

  • Try this:

    ModifyAliases modifyAliases = new ModifyAliases.Builder(new RemoveAliasMapping.Builder("oldIndex", "alias").build()).build();
    JestResult result = client.execute(modifyAliases);