IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
MultiSearch API
editMultiSearch API
editSee MultiSearch API Query documentation
SearchRequestBuilder srb1 = node.client() .prepareSearch().setQuery(QueryBuilders.queryString("elasticsearch")).setSize(1); SearchRequestBuilder srb2 = node.client() .prepareSearch().setQuery(QueryBuilders.matchQuery("name", "kimchy")).setSize(1); MultiSearchResponse sr = node.client().prepareMultiSearch() .add(srb1) .add(srb2) .execute().actionGet(); // You will get all individual responses from MultiSearchResponse#getResponses() long nbHits = 0; for (MultiSearchResponse.Item item : sr.getResponses()) { SearchResponse response = item.getResponse(); nbHits += response.getHits().getTotalHits(); }