Source:
<code>public static SearchResponse countTestHelper(final String indexName, String query, final Integer expected, final Path path, final TimeValue timeout, final String... fields) throws Exception { final SearchResponse[] response = new SearchResponse[1]; staticLogger.info(" ---> Waiting up to seconds for documents in index {}", timeout.toString(), expected == null ? "some" : expected, indexName); assertThat("We waited for " + timeout.toString() + " but no document has been added", awaitBusy(() -> { long totalHits; SearchRequest.Builder sr = SearchRequest.builder(); if (query != null) { sr.setQuery(query); } if (fields.length > 0) { sr.setFields(fields); } <START> sr.setSize(0); <END> try { response[0] = elasticsearchClient.search(indexName, FsCrawlerUtil.INDEX_TYPE_DOC, sr.build()); } catch (IOException e) { staticLogger.warn("error caught", e); return false; } staticLogger.trace("result {}", response[0].toString()); totalHits = response[0].getHits().getTotal(); if (expected == null) { return (totalHits >= 1); } else { if (expected == totalHits) { staticLogger.debug(" ---> expected and got documents in [{}]", expected, totalHits, indexName); return true; } else { staticLogger.debug(" ---> expecting but got documents in [{}]", expected, totalHits, indexName); if (path != null) { staticLogger.debug(" ---> content of [{}]:", path); try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) { for (Path file : directoryStream) { staticLogger.debug(" - {}", file.getFileName().toString(), Files.getLastModifiedTime(file)); } } catch (IOException ex) { staticLogger.error("can not read content of [{}]:", path); } } return false; } } }, timeout.millis(), TimeUnit.MILLISECONDS), equalTo(true)); return response[0]; }</code><technical_language>set that. I bad impact some tests read response elasticsearch on</technical_language>

Target:
public static SearchResponse countTestHelper(final String indexName, String query, final Integer expected, final Path path, final TimeValue timeout, final String... fields) throws Exception { final SearchResponse[] response = new SearchResponse[1]; staticLogger.info(" ---> Waiting up to seconds for documents in index {}", timeout.toString(), expected == null ? "some" : expected, indexName); assertThat("We waited for " + timeout.toString() + " but no document has been added", awaitBusy(() -> { long totalHits; SearchRequest.Builder sr = SearchRequest.builder(); if (query != null) { sr.setQuery(query); } if (fields.length > 0) { sr.setFields(fields); } try { response[0] = elasticsearchClient.search(indexName, FsCrawlerUtil.INDEX_TYPE_DOC, sr.build()); } catch (IOException e) { staticLogger.warn("error caught", e); return false; } staticLogger.trace("result {}", response[0].toString()); totalHits = response[0].getHits().getTotal(); if (expected == null) { return (totalHits >= 1); } else { if (expected == totalHits) { staticLogger.debug(" ---> expected and got documents in [{}]", expected, totalHits, indexName); return true; } else { staticLogger.debug(" ---> expecting but got documents in [{}]", expected, totalHits, indexName); if (path != null) { staticLogger.debug(" ---> content of [{}]:", path); try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) { for (Path file : directoryStream) { staticLogger.debug(" - {}", file.getFileName().toString(), Files.getLastModifiedTime(file)); } } catch (IOException ex) { staticLogger.error("can not read content of [{}]:", path); } } return false; } } }, timeout.millis(), TimeUnit.MILLISECONDS), equalTo(true)); return response[0]; }