From 240f8fa5a85f6ffa69b3ccf1b16dcbe852a124d0 Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Thu, 19 Sep 2024 00:02:59 +0200 Subject: [PATCH] Deleting events which do not exist in the search index Deleting an event from the search service fails completely if the event is not in OpenSearch. It should be happy that it's already gone instead and continue. This fixes #6174 --- .../org/opencastproject/search/impl/SearchServiceIndex.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/search-service-impl/src/main/java/org/opencastproject/search/impl/SearchServiceIndex.java b/modules/search-service-impl/src/main/java/org/opencastproject/search/impl/SearchServiceIndex.java index 8f10ff4af51..25c9377df78 100644 --- a/modules/search-service-impl/src/main/java/org/opencastproject/search/impl/SearchServiceIndex.java +++ b/modules/search-service-impl/src/main/java/org/opencastproject/search/impl/SearchServiceIndex.java @@ -355,7 +355,11 @@ public boolean deleteSynchronously(final String mediaPackageId) throws SearchExc var updateRequst = new UpdateRequest(INDEX_NAME, mediaPackageId) .doc(gson.toJson(json), XContentType.JSON); esIndex.getClient().update(updateRequst, RequestOptions.DEFAULT); - + } catch (ElasticsearchStatusException e) { + if (e.status().getStatus() != RestStatus.NOT_FOUND.getStatus()) { + throw e; + } + logger.warn("Event {} is not in the search index. Skipping deletion", mediaPackageId); } catch (IOException e) { throw new SearchException("Could not delete episode " + mediaPackageId + " from index", e); }