Ejemplo n.º 1
0
  public void testDeepScrollingDoesNotBlowUp() throws Exception {
    client()
        .prepareIndex("index", "type", "1")
        .setSource("field", "value")
        .setRefresh(true)
        .execute()
        .get();

    for (SearchType searchType : SearchType.values()) {
      SearchRequestBuilder builder =
          client()
              .prepareSearch("index")
              .setSearchType(searchType)
              .setQuery(QueryBuilders.matchAllQuery())
              .setSize(Integer.MAX_VALUE)
              .setScroll("1m");

      SearchResponse response = builder.execute().actionGet();
      try {
        ElasticsearchAssertions.assertHitCount(response, 1l);
      } finally {
        String scrollId = response.getScrollId();
        if (scrollId != null) {
          clearScroll(scrollId);
        }
      }
    }
  }