Skip to content

Commit

Permalink
Issue #528: Add ignore_unavailable to prevent no such index exception
Browse files Browse the repository at this point in the history
  • Loading branch information
cbianco committed Jul 26, 2023
1 parent b4f3c31 commit 82b9075
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
import io.openk9.datasource.service.util.Tuple2;
import io.smallrye.mutiny.Uni;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.Set;

@ApplicationScoped
Expand Down Expand Up @@ -155,8 +157,18 @@ public Uni<DataIndex> deleteById(long entityId) {
.onItem()
.transformToUni(dataIndex -> Uni.createFrom()
.<AcknowledgedResponse>emitter(emitter -> {

DeleteIndexRequest deleteIndexRequest =
new DeleteIndexRequest(dataIndex.getName());

deleteIndexRequest
.indicesOptions(
IndicesOptions.fromMap(
Map.of("ignore_unavailable", true),
deleteIndexRequest.indicesOptions()
)
);

try {
AcknowledgedResponse delete = client.indices().delete(
deleteIndexRequest,
Expand Down

0 comments on commit 82b9075

Please sign in to comment.