Skip to content

Commit

Permalink
feat(repository-elasticsearch): add a raw delete query
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Jul 4, 2022
1 parent 2e32fce commit f305477
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.opensearch.action.ShardOperationFailedException;
import org.opensearch.action.admin.indices.settings.get.GetSettingsRequest;
import org.opensearch.action.admin.indices.settings.get.GetSettingsResponse;
import org.opensearch.action.delete.DeleteRequest;
import org.opensearch.action.delete.DeleteResponse;
import org.opensearch.action.get.GetRequest;
import org.opensearch.action.get.GetResponse;
import org.opensearch.action.index.IndexRequest;
Expand Down Expand Up @@ -237,6 +239,20 @@ protected UpdateResponse deleteRequest(String index, String id) {
return this.updateRequest(index, id, delete);
}

protected DeleteResponse rawDeleteRequest(String index, String id) {
DeleteRequest request = new DeleteRequest(this.indicesConfigs.get(index).getIndex(), id);
request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);

try {
DeleteResponse response = client.delete(request, RequestOptions.DEFAULT);
handleWriteErrors(response);

return response;
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected SearchRequest searchRequest(String index, SearchSourceBuilder sourceBuilder, boolean scroll) {
SearchRequest searchRequest = new SearchRequest()
.indices(this.indicesConfigs.get(index).getIndex())
Expand Down

0 comments on commit f305477

Please sign in to comment.