From 68a35ea86f556bede3e940e5e678bf2d7b13a078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Prante?= Date: Fri, 25 Aug 2023 10:52:10 +0200 Subject: [PATCH] just issue a warning when trying to delete an index which is not found --- .../org/xbib/elx/common/AbstractAdminClient.java | 15 ++++++++++----- gradle.properties | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/elx-common/src/main/java/org/xbib/elx/common/AbstractAdminClient.java b/elx-common/src/main/java/org/xbib/elx/common/AbstractAdminClient.java index 9750f7a..79f8380 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/AbstractAdminClient.java +++ b/elx-common/src/main/java/org/xbib/elx/common/AbstractAdminClient.java @@ -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 diff --git a/gradle.properties b/gradle.properties index e05d576..9de806e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group = org.xbib name = elx -version = 7.10.2.30 +version = 7.10.2.31 org.gradle.warning.mode = ALL