You did not tell which version you are using, but with a simple test on 8.8 in Kibana dev console:
POST /_reindex
{
"source": {
"index": "doesnotexist"
},
"dest": {
"index": "foo"
}
}
I'm getting a 404 error:
{
"error": {
"root_cause": [
{
"type": "index_not_found_exception",
"reason": "no such index [doesnotexist]",
"resource.type": "index_or_alias",
"resource.id": "doesnotexist",
"index_uuid": "_na_",
"index": "doesnotexist"
}
],
"type": "index_not_found_exception",
"reason": "no such index [doesnotexist]",
"resource.type": "index_or_alias",
"resource.id": "doesnotexist",
"index_uuid": "_na_",
"index": "doesnotexist"
},
"status": 404
}
I'd expect the same to happen in the Java Client. I just checked it with the new java client:
try {
client.reindex(rr -> rr.source(s -> s.index("does-not-exists")).dest(d -> d.index("foo")));
} catch (ElasticsearchException e) {
logger.info("Got error {}", e.response());
}
This gives:
12:05:21,952 INFO [f.p.t.e.h.EsClientIT] Got error ErrorResponse: {"error":{"index_uuid":"_na_","index":"does-not-exists","resource.type":"index_or_alias","resource.id":"does-not-exists","type":"index_not_found_exception","reason":"no such index [does-not-exists]","root_cause":[{"index_uuid":"_na_","index":"does-not-exists","resource.type":"index_or_alias","resource.id":"does-not-exists","type":"index_not_found_exception","reason":"no such index [does-not-exists]"}]},"status":404}