Beefed up DeleteByQueryTests to run not just against a single document

This commit is contained in:
Simon Willnauer 2014-02-11 16:23:08 +01:00
parent 91900ef346
commit 0b4bf88dae
1 changed files with 6 additions and 5 deletions

View File

@ -48,13 +48,14 @@ public class DeleteByQueryTests extends ElasticsearchIntegrationTest {
@Test
public void testDeleteAllOneIndex() {
String json = "{" + "\"user\":\"kimchy\"," + "\"postDate\":\"2013-01-30\"," + "\"message\":\"trying out Elastic Search\"" + "}";
client().prepareIndex("twitter", "tweet").setSource(json).setRefresh(true).execute().actionGet();
final long iters = randomIntBetween(1, 50);
for (int i = 0; i < iters; i++) {
client().prepareIndex("twitter", "tweet", "" + i).setSource(json).execute().actionGet();
}
refresh();
SearchResponse search = client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
assertThat(search.getHits().totalHits(), equalTo(1l));
assertThat(search.getHits().totalHits(), equalTo(iters));
DeleteByQueryRequestBuilder deleteByQueryRequestBuilder = client().prepareDeleteByQuery();
deleteByQueryRequestBuilder.setQuery(QueryBuilders.matchAllQuery());