@Test
  public void testBulk_withIndexAndDeleteItems() throws Exception {
    prepareIndex(1);
    BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
    for (int i = 0; i < 10; i++) {
      bulkRequestBuilder.add(client().prepareIndex("idx", "type").setSource("{}"));
    }

    BulkResponse bulkResponse = bulkRequestBuilder.get();
    bulkRequestBuilder = client().prepareBulk();
    for (BulkItemResponse item : bulkResponse) {
      assertThat(item.isFailed(), equalTo(false));
      assertShardInfo(item.getResponse());
      bulkRequestBuilder.add(client().prepareDelete("idx", "type", item.getId()));
    }

    bulkResponse = bulkRequestBuilder.get();
    for (BulkItemResponse item : bulkResponse) {
      assertThat(item.isFailed(), equalTo(false));
      assertShardInfo(item.getResponse());
    }
  }
  @Test
  public void testBulk_withUpdateItems() throws Exception {
    prepareIndex(1);
    BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
    for (int i = 0; i < 10; i++) {
      bulkRequestBuilder.add(
          client()
              .prepareUpdate("idx", "type", Integer.toString(i))
              .setDoc("{}")
              .setDocAsUpsert(true));
    }

    BulkResponse bulkResponse = bulkRequestBuilder.get();
    for (BulkItemResponse item : bulkResponse) {
      assertThat(item.isFailed(), equalTo(false));
      assertShardInfo(item.getResponse());
    }
  }