@Test
public void testFailure() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")));
DeleteByQueryResponse response = client().prepareDeleteByQuery(indexOrAlias())
.setQuery(QueryBuilders.hasChildQuery("type", QueryBuilders.matchAllQuery()))
.execute().actionGet();
NumShards twitter = getNumShards("test");
assertThat(response.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(response.getIndex("test").getSuccessfulShards(), equalTo(0));
assertThat(response.getIndex("test").getFailedShards(), equalTo(twitter.numPrimaries));
assertThat(response.getIndices().size(), equalTo(1));
assertThat(response.getIndices().get("test").getFailedShards(), equalTo(twitter.numPrimaries));
assertThat(response.getIndices().get("test").getFailures().length, equalTo(twitter.numPrimaries));
for (ShardOperationFailedException failure : response.getIndices().get("test").getFailures()) {
assertThat(failure.reason(), containsString("[test] [has_child] query and filter unsupported in delete_by_query api"));
assertThat(failure.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(failure.shardId(), greaterThan(-1));
}
}