Skip to content

Commit

Permalink
Added mget for high level client (opensearch-project#428)
Browse files Browse the repository at this point in the history
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
  • Loading branch information
owaiskazi19 authored Feb 10, 2023
1 parent e8ec093 commit 985154b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/opensearch/sdk/SDKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.opensearch.action.delete.DeleteResponse;
import org.opensearch.action.get.GetRequest;
import org.opensearch.action.get.GetResponse;
import org.opensearch.action.get.MultiGetRequest;
import org.opensearch.action.get.MultiGetResponse;
import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.index.IndexResponse;
import org.opensearch.action.search.SearchRequest;
Expand Down Expand Up @@ -252,6 +254,15 @@ public void get(GetRequest request, ActionListener<GetResponse> listener) {
restHighLevelClient.getAsync(request, RequestOptions.DEFAULT, listener);
}

/**
* Gets all the documents that match the criteria
* @param request The multiGet Request
* @param listener A listener to be notified with a result
*/
public void multiGet(MultiGetRequest request, ActionListener<MultiGetResponse> listener) {
restHighLevelClient.mgetAsync(request, RequestOptions.DEFAULT, listener);
}

/**
* Deletes a document from the index based on the index, and id.
*
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 @@ -15,6 +15,7 @@
import org.opensearch.action.admin.indices.delete.DeleteIndexRequest;
import org.opensearch.action.delete.DeleteRequest;
import org.opensearch.action.get.GetRequest;
import org.opensearch.action.get.MultiGetRequest;
import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.client.Cancellable;
Expand Down Expand Up @@ -73,6 +74,7 @@ public void testSDKRestClient() throws Exception {
// Would really prefer to mock/verify the method calls but they are final
assertDoesNotThrow(() -> restClient.index(new IndexRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.get(new GetRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.multiGet(new MultiGetRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.delete(new DeleteRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertDoesNotThrow(() -> restClient.search(new SearchRequest(), ActionListener.wrap(r -> {}, e -> {})));

Expand Down

0 comments on commit 985154b

Please sign in to comment.