Skip to content

Commit

Permalink
Adds DeleteByQuery Request for SDKRestClient (#708) (#710)
Browse files Browse the repository at this point in the history
(cherry picked from commit b30bec4)

Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent c149ae1 commit 6d3b7cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/org/opensearch/sdk/SDKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.rest_client.RestClientTransport;
import org.opensearch.index.reindex.BulkByScrollResponse;
import org.opensearch.index.reindex.DeleteByQueryRequest;

/**
* This class creates SDKClient for an extension to make requests to OpenSearch
Expand Down Expand Up @@ -438,6 +440,17 @@ public void delete(DeleteRequest request, ActionListener<DeleteResponse> listene
restHighLevelClient.deleteAsync(request, options, listener);
}

/**
* Deletes a document from the index based on the query.
*
* @param request The delete by query request
* @param listener A listener to be notified with a result
*
*/
public void deleteByQueryAsync(DeleteByQueryRequest request, ActionListener<BulkByScrollResponse> listener) {
restHighLevelClient.deleteByQueryAsync(request, options, listener);
}

/**
* Search across one or more indices with a query.
*
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/opensearch/sdk/TestSDKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.opensearch.client.opensearch.cluster.OpenSearchClusterClient;
import org.opensearch.client.opensearch.indices.OpenSearchIndicesAsyncClient;
import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient;
import org.opensearch.index.reindex.DeleteByQueryRequest;
import org.opensearch.sdk.SDKClient.SDKClusterAdminClient;
import org.opensearch.sdk.SDKClient.SDKIndicesClient;
import org.opensearch.sdk.SDKClient.SDKRestClient;
Expand Down Expand Up @@ -100,6 +101,7 @@ public void testSDKRestClient() throws Exception {
assertDoesNotThrow(() -> restClient.multiGet(new MultiGetRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.update(new UpdateRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.delete(new DeleteRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.deleteByQueryAsync(new DeleteByQueryRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.search(new SearchRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.multiSearch(new MultiSearchRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.bulk(new BulkRequest(), ActionListener.wrap(r -> {}, e -> {})));
Expand Down

0 comments on commit 6d3b7cb

Please sign in to comment.