final SearchScroll scrollRequest = new SearchScroll.Builder(scrollId, "1m").build(); final JestResult scrollResult = JestUtils.execute(jestClient, scrollRequest, () -> "Couldn't process result of scroll query"); final JsonNode scrollHits = scrollResult.getJsonObject().path("hits").path("hits");
protected SearchScroll(Builder builder) { super(builder); if(builder.getScrollId().length() > MAX_SCROLL_ID_LENGTH) { this.restMethodName = "POST"; // represent scroll_id in json for request body JsonObject scrollObject = new JsonObject(); scrollObject.addProperty(SCROLL_ID, builder.getScrollId()); this.payload = scrollObject.toString(); } else { this.restMethodName = "GET"; } }
public Builder(String scrollId, String scroll) { this.scrollId = scrollId; if (scrollId.length() <= MAX_SCROLL_ID_LENGTH) { setParameter(Parameters.SCROLL_ID, scrollId); } setParameter(Parameters.SCROLL, scroll); }
}; while (true) { final SearchScroll scrollRequest = new SearchScroll.Builder(scrollId, "1m").build(); final JestResult scrollResult = JestUtils.execute(jestClient, scrollRequest, () -> "Couldn't process result of scroll query"); final JsonNode scrollHits = scrollResult.getJsonObject().path("hits").path("hits");
final SearchScroll searchScroll = new SearchScroll.Builder(scrollId, "1m").build(); final JestResult result = client.execute(searchScroll); if (!result.isSucceeded()) {
SearchScroll scroll = new SearchScroll.Builder(scrollId, new TimeValue(ELASTIC_SEARCH_SCROLL_KEEP_ALIVE_TIME).toString()).build(); jestResult = jestClientHelper.execute(scroll);
results = client.execute(new SearchScroll.Builder(scroll_id.getAsString(), "6m").build()); scroll_id = results.getJsonObject().get("_scroll_id"); JsonArray thisResultAsJsonArray = results.getJsonObject().get("hits").getAsJsonObject().get("hits").getAsJsonArray();
SearchScroll scroll = new SearchScroll.Builder(scrollId, new TimeValue(ELASTIC_SEARCH_SCROLL_KEEP_ALIVE_TIME).toString()).build(); jestResult = jestClientHelper.execute(scroll);
private synchronized JestResult scrollResults(String scrollId, int retry, JestClient client) throws InterruptedException { if (client != null) { final SearchScroll scroll = new SearchScroll.Builder(scrollId, SCROLL_TIME_SESSION).build(); try { final JestResult result = client.execute(scroll); log.debug("Completed scroll query. Succeeded: {}", result.isSucceeded()); return result; } catch (IOException e) { log.warn("Error in scroll request query: {}", e.getMessage(), e); if(retry > ES_MAX_TRIES) { log.error("Error in scroll request: reached maximum number of scroll tries [{}].", retry); throw new RuntimeException("Error in scroll request query: " + e.getMessage(), e); } else { Thread.sleep((retry + 1) * ES_WAIT_TIME); return scrollResults(scrollId, retry + 1, client); } } } log.error("Error in scroll request query: ES client has not been initialized, client is null."); throw new RuntimeException("Error in scroll request query: ES client has not been initialized, client is null."); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private void fetch() throws StorageException { try { Builder builder = new SearchScroll.Builder(scrollId, "1m"); SearchScroll scroll = new SearchScroll(builder) { @Override public JestResult createNewElasticSearchResult(String responseBody, int statusCode, String reasonPhrase, Gson gson) { return createNewElasticSearchResult(new SearchResult(gson), responseBody, statusCode, reasonPhrase, gson); } }; SearchResult response = (SearchResult) esClient.execute(scroll); if (!response.isSucceeded()) { throw new StorageException("Scrolled fetch failed " + response.getErrorMessage()); } this.hits = (List) response.getHits(Map.class); } catch (IOException e) { throw new StorageException(e); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private void fetch() throws StorageException { try { Builder builder = new SearchScroll.Builder(scrollId, "1m"); SearchScroll scroll = new SearchScroll(builder) { @Override public JestResult createNewElasticSearchResult(String responseBody, int statusCode, String reasonPhrase, Gson gson) { return createNewElasticSearchResult(new SearchResult(gson), responseBody, statusCode, reasonPhrase, gson); } }; SearchResult response = (SearchResult) esClient.execute(scroll); if (!response.isSucceeded()) { throw new StorageException("Scrolled fetch failed " + response.getErrorMessage()); } this.hits = (List) response.getHits(Map.class); } catch (IOException e) { throw new StorageException(e); } }
protected SearchScroll(Builder builder) { super(builder); if(builder.getScrollId().length() > MAX_SCROLL_ID_LENGTH) { this.restMethodName = "POST"; // represent scroll_id in json for request body this.payload = "{\"scroll_id\":\"" + builder.getScrollId() + "\"}"; } else { this.restMethodName = "GET"; } setURI(buildURI()); }
public JestResult readMoreFromSearch(String scrollId, Long size) throws IOException { SearchScroll scroll = new SearchScroll.Builder(scrollId, "1m") .setParameter(Parameters.SIZE, size).build(); JestResult searchResult = EsClientConn.getJestClient().execute(scroll); return searchResult; }
public <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz, JestScrollResultMapper mapper) { SearchScroll scroll = new SearchScroll.Builder(scrollId, scrollTimeInMillis + "ms").build(); SearchScrollResult response = new SearchScrollResult(execute(scroll)); return mapper.mapResults(response, clazz); }
private JestResult getNextScrollResult() throws IOException { final SearchScroll.Builder searchBuilder = new SearchScroll.Builder(scrollId, scroll); return jestClient.execute(searchBuilder.build()); }
public Builder(String scrollId, String scroll) { this.scrollId = scrollId; if (scrollId.length() <= MAX_SCROLL_ID_LENGTH) { setParameter(Parameters.SCROLL_ID, scrollId); } setParameter(Parameters.SCROLL, scroll); }
protected SearchScroll(Builder builder) { super(builder); if(builder.getScrollId().length() > MAX_SCROLL_ID_LENGTH) { this.restMethodName = "POST"; // represent scroll_id in json for request body JsonObject scrollObject = new JsonObject(); scrollObject.addProperty(SCROLL_ID, builder.getScrollId()); this.payload = scrollObject.toString(); } else { this.restMethodName = "GET"; } }
@Override public <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz) { SearchScroll scroll = new SearchScroll.Builder(scrollId, scrollTimeInMillis + "ms").build(); SearchScrollResult response = new SearchScrollResult(execute(scroll)); return resultsMapper.mapResults(response, clazz); }
public Builder(String scrollId, String scroll) { this.scrollId = scrollId; if (scrollId.length() <= MAX_SCROLL_ID_LENGTH) { setParameter(Parameters.SCROLL_ID, scrollId); } setParameter(Parameters.SCROLL, scroll); }
private JestResult getNextScrollResult() throws IOException { final SearchScroll.Builder searchBuilder = new SearchScroll.Builder(scrollId, scroll); return jestClient.execute(searchBuilder.build()); }