How to perform atomic operations using a java client

java client

I want to do the following with a java client.
I couldn't find a way to do it in the documentation.

POST _aliases
{
  "actions": [
    {
      "remove": {
        "index": "logs-nginx.access-prod",
        "alias": "logs"
      }
    },
    {
      "add": {
        "index": "logs-my_app-default",
        "alias": "logs"
      }
    }
  ]
}

From Elastic Search to Elasticsearch

Added language-clients

Hello and welcome! This endpoint is a bit hard to find in the client, but here it is:

esClient.indices()
    .updateAliases(u -> u
        .actions(
            Action.of(a -> a
                .remove(r -> r
                    .index("logs-nginx.access-prod")
                    .alias("logs"))),
            Action.of(a -> a
                .add(ad -> ad
                    .index("logs-my_app-default")
                    .alias("logs")))));

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.