diff --git a/src/main/java/org/opensearch/sdk/SDKClient.java b/src/main/java/org/opensearch/sdk/SDKClient.java index 58a2aaca..ddb7af50 100644 --- a/src/main/java/org/opensearch/sdk/SDKClient.java +++ b/src/main/java/org/opensearch/sdk/SDKClient.java @@ -36,6 +36,8 @@ import org.opensearch.action.get.MultiGetResponse; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; +import org.opensearch.action.search.MultiSearchRequest; +import org.opensearch.action.search.MultiSearchResponse; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.TransportAction; @@ -437,6 +439,16 @@ public void search(SearchRequest request, ActionListener listene restHighLevelClient.searchAsync(request, RequestOptions.DEFAULT, listener); } + /** + * Search across all documents that match the criteria + * + * @param request The multiSearch Request + * @param listener A listener to be notified with a result + */ + public void multiSearch(MultiSearchRequest request, ActionListener listener) { + restHighLevelClient.msearchAsync(request, RequestOptions.DEFAULT, listener); + } + /** * Sends a request to the OpenSearch cluster that the client points to. * diff --git a/src/test/java/org/opensearch/sdk/TestSDKClient.java b/src/test/java/org/opensearch/sdk/TestSDKClient.java index 1dcfca81..5d2cedcb 100644 --- a/src/test/java/org/opensearch/sdk/TestSDKClient.java +++ b/src/test/java/org/opensearch/sdk/TestSDKClient.java @@ -18,6 +18,7 @@ import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.MultiGetRequest; import org.opensearch.action.index.IndexRequest; +import org.opensearch.action.search.MultiSearchRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.update.UpdateRequest; import org.opensearch.client.Cancellable; @@ -96,6 +97,7 @@ public void testSDKRestClient() throws Exception { assertDoesNotThrow(() -> restClient.update(new UpdateRequest(), ActionListener.wrap(r -> {}, e -> {}))); assertDoesNotThrow(() -> restClient.delete(new DeleteRequest(), ActionListener.wrap(r -> {}, e -> {}))); assertDoesNotThrow(() -> restClient.search(new SearchRequest(), ActionListener.wrap(r -> {}, e -> {}))); + assertDoesNotThrow(() -> restClient.multiSearch(new MultiSearchRequest(), ActionListener.wrap(r -> {}, e -> {}))); expectThrows(ConnectException.class, () -> restClient.performRequest(new Request("GET", "/"))); sdkClient.doCloseHighLevelClient();