|
21 | 21 |
|
22 | 22 | import com.google.common.collect.Sets; |
23 | 23 | import org.elasticsearch.ElasticSearchException; |
| 24 | +import org.elasticsearch.action.search.MultiSearchResponse; |
24 | 25 | import org.elasticsearch.action.search.SearchPhaseExecutionException; |
25 | 26 | import org.elasticsearch.action.search.SearchResponse; |
26 | 27 | import org.elasticsearch.client.Client; |
27 | 28 | import org.elasticsearch.client.Requests; |
28 | 29 | import org.elasticsearch.common.Unicode; |
29 | 30 | import org.elasticsearch.common.xcontent.XContentBuilder; |
| 31 | +import org.elasticsearch.index.query.QueryBuilders; |
30 | 32 | import org.elasticsearch.search.Scroll; |
31 | 33 | import org.elasticsearch.search.SearchHit; |
32 | 34 | import org.elasticsearch.search.builder.SearchSourceBuilder; |
@@ -369,6 +371,28 @@ public void testFailedSearchWithWrongFrom() throws Exception { |
369 | 371 | logger.info("Done Testing failed search"); |
370 | 372 | } |
371 | 373 |
|
| 374 | + @Test |
| 375 | + public void testFailedMultiSearchWithWrongQuery() throws Exception { |
| 376 | + logger.info("Start Testing failed multi search with a wrong query"); |
| 377 | + |
| 378 | + MultiSearchResponse response = client.prepareMultiSearch() |
| 379 | + // Add custom score query with missing script |
| 380 | + .add(client.prepareSearch("test").setQuery(QueryBuilders.customScoreQuery(QueryBuilders.termQuery("nid", 1)))) |
| 381 | + .add(client.prepareSearch("test").setQuery(QueryBuilders.termQuery("nid", 2))) |
| 382 | + .add(client.prepareSearch("test").setQuery(QueryBuilders.matchAllQuery())) |
| 383 | + .execute().actionGet(); |
| 384 | + assertThat(response.responses().length, equalTo(3)); |
| 385 | + assertThat(response.responses()[0].failureMessage(), notNullValue()); |
| 386 | + |
| 387 | + assertThat(response.responses()[1].failureMessage(), nullValue()); |
| 388 | + assertThat(response.responses()[1].getResponse().hits().hits().length, equalTo(1)); |
| 389 | + |
| 390 | + assertThat(response.responses()[2].failureMessage(), nullValue()); |
| 391 | + assertThat(response.responses()[2].getResponse().hits().hits().length, equalTo(10)); |
| 392 | + |
| 393 | + logger.info("Done Testing failed search"); |
| 394 | + } |
| 395 | + |
372 | 396 | private void index(Client client, String id, String nameValue, int age) throws IOException { |
373 | 397 | client.index(Requests.indexRequest("test").type("type1").id(id).source(source(id, nameValue, age))).actionGet(); |
374 | 398 | } |
|
0 commit comments