just issue a warning when trying to delete an index which is not found

This commit is contained in:
Jörg Prante 2023-08-25 10:52:10 +02:00
parent f3a386076e
commit 68a35ea86f
2 changed files with 11 additions and 6 deletions

View file

@ -49,6 +49,7 @@ import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
@ -163,12 +164,16 @@ public abstract class AbstractAdminClient extends AbstractBasicClient implements
return;
}
ensureClientIsPresent();
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest().indices(indexName);
AcknowledgedResponse acknowledgedResponse = client.execute(DeleteIndexAction.INSTANCE, deleteIndexRequest).actionGet();
if (acknowledgedResponse.isAcknowledged()) {
logger.info("index " + indexName + " deleted");
try {
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest().indices(indexName);
AcknowledgedResponse acknowledgedResponse = client.execute(DeleteIndexAction.INSTANCE, deleteIndexRequest).actionGet();
if (acknowledgedResponse.isAcknowledged()) {
logger.info("index " + indexName + " deleted");
}
waitForHealthyCluster();
} catch (IndexNotFoundException e) {
logger.log(Level.WARNING, "index " + indexName + " not found, skipping deletion");
}
waitForHealthyCluster();
}
@Override

View file

@ -1,5 +1,5 @@
group = org.xbib
name = elx
version = 7.10.2.30
version = 7.10.2.31
org.gradle.warning.mode = ALL