Skip to content

Commit

Permalink
Added multi search for Search Detector (#632)
Browse files Browse the repository at this point in the history
Signed-off-by: Owais Kazi <[email protected]>
(cherry picked from commit fe9d59d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Apr 3, 2023
1 parent f9dba87 commit ea32e15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/opensearch/sdk/SDKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -437,6 +439,16 @@ public void search(SearchRequest request, ActionListener<SearchResponse> 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<MultiSearchResponse> listener) {
restHighLevelClient.msearchAsync(request, RequestOptions.DEFAULT, listener);
}

/**
* Sends a request to the OpenSearch cluster that the client points to.
*
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 @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ea32e15

Please sign in to comment.