@SuppressWarnings("unused") // for errorprone
  private void assertNoActiveScrolls() throws Exception {
    // get node stats
    final Response response = restClient
            .performRequest(new Request("GET", "/_nodes/stats/indices/search"));

    try (InputStream is = response.getEntity().getContent()) {
      final ObjectNode node = backend().objectMapper.readValue(is, ObjectNode.class);
      final String path = "/indices/search/scroll_current";
      final JsonNode scrollCurrent = node.with("nodes").elements().next().at(path);
      if (scrollCurrent.isMissingNode()) {
        throw new IllegalStateException("Couldn't find node at " + path);
      }

      final int activeScrolls = scrollCurrent.asInt();
      if (activeScrolls != 0) {
        throw new AssertionError(String.format("Expected no active scrolls but got %d. " +
                "Current index stats %s", activeScrolls, node));
      }
    }
  }
Ensures there are no pending scroll contexts in elastic search cluster.
Queries {@code /_nodes/stats/indices/search} endpoint.
@see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html">Indices Stats</a>
criteria/elasticsearch/test/org/immutables/criteria/elasticsearch/ScrollingTest.java