From ddb77667f83f289717356230907a06fd1c99e016 Mon Sep 17 00:00:00 2001 From: Tobias Hotz Date: Thu, 7 Nov 2024 16:50:48 +0100 Subject: [PATCH] Fix UserSelectionsApiTest being too strict about the submittor --- .../java/org/fao/geonet/index/es/EsRestClient.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index/src/main/java/org/fao/geonet/index/es/EsRestClient.java b/index/src/main/java/org/fao/geonet/index/es/EsRestClient.java index 1f1b6be2507..688acb65654 100644 --- a/index/src/main/java/org/fao/geonet/index/es/EsRestClient.java +++ b/index/src/main/java/org/fao/geonet/index/es/EsRestClient.java @@ -336,13 +336,13 @@ public SearchResponse query(String index, Query.Builder queryBuilder, Query.Buil } - public String deleteByQuery(String index, String query) throws Exception { + public void deleteByQuery(String index, String query) throws Exception { if (!activated) { - return ""; + throw new IllegalStateException("Index not yet activated."); } DeleteByQueryRequest request = DeleteByQueryRequest.of( - b -> b.index(new ArrayList<>(Arrays.asList(index))) + b -> b.index(index) .q(query) .refresh(true)); @@ -350,9 +350,7 @@ public String deleteByQuery(String index, String query) throws Exception { client.deleteByQuery(request); - if (deleteByQueryResponse.deleted() >= 0) { - return String.format("Record removed. %s.", deleteByQueryResponse.deleted()); - } else { + if (!deleteByQueryResponse.failures().isEmpty()) { StringBuilder stringBuilder = new StringBuilder(); deleteByQueryResponse.failures().forEach(f -> stringBuilder.append(f.toString()));