Example of error response for POST _aliases API


we are using 8.x JAVA client to communicate with Elasticsearch. In case of trying to handle unexpected error for updating aliases the documentation is saying nothing - Aliases API | Elasticsearch Guide [8.9] | Elastic.

The Java API of the client is saying for acknowledged field of co.elastic.clients.elasticsearch.indices.UpdateAliasesResponse class, that:

Required - For a successful response, this value is always true. On failure, an exception is returned instead.

But what is it exactly? For example if I try to update alias for non existing index, the 404 is returned. The very similar behaviour for alias name. But is there another scenario when Elasticsearch can answer differently? 500 or something else, and with which payload?

I would like to write test for this scenario but I don't know how I should simulate response of Elasticsearch.


All exception responses have the same overall shape, which looks like this:

< HTTP/1.1 503 Service Unavailable
< X-elastic-product: Elasticsearch
< content-type: application/json
< content-encoding: gzip
< content-length: 145
  "error" : {
    "root_cause" : [
        "type" : "master_not_discovered_exception",
        "reason" : null
    "type" : "master_not_discovered_exception",
    "reason" : null
  "status" : 503

Hi David, thank you very much for your answer ;).

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