public <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz) { SearchScrollRequest request = new SearchScrollRequest(scrollId); request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis)); SearchResponse response; try { response = client.searchScroll(request); } catch (IOException e) { throw new ElasticsearchException("Error for search request with scroll: " + request.toString(), e); } return resultsMapper.mapResults(response, clazz, Pageable.unpaged()); }
public <T> Page<T> continueScroll(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz, SearchResultMapper mapper) { SearchScrollRequest request = new SearchScrollRequest(scrollId); request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis)); SearchResponse response; try { response = client.searchScroll(request); } catch (IOException e) { throw new ElasticsearchException("Error for search request with scroll: " + request.toString(), e); } return mapper.mapResults(response, clazz, Pageable.unpaged()); }
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); scrollRequest.scroll(TimeValue.timeValueSeconds(30)); SearchResponse searchScrollResponse = client.searchScroll(scrollRequest); scrollId = searchScrollResponse.getScrollId(); hits = searchScrollResponse.getHits();
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); scrollRequest.scroll(scroll); searchResponse = client.searchScroll(scrollRequest); scrollId = searchResponse.getScrollId(); searchHits = searchResponse.getHits().getHits();
private ScrollingSearchResult.ScrollingBatch<FactDocument> fetchNextFactsBatch(String scrollId) { SearchResponse response; try { response = clientFactory.getHighLevelClient().searchScroll(new SearchScrollRequest() .scrollId(scrollId) .scroll(searchScrollExpiration)); } catch (IOException ex) { LOGGER.warning(ex, "Could not perform request to retrieve next batch of search results. Stop scrolling."); return ScrollingSearchResult.emptyBatch(); } if (response.status() != RestStatus.OK) { LOGGER.warning("Could not retrieve next batch of search results (response code %s). Stop scrolling.", response.status()); return ScrollingSearchResult.emptyBatch(); } return createFactsBatch(response); }
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); scrollRequest.scroll(scroll); searchResponse = client.searchScroll(scrollRequest); scrollId = searchResponse.getScrollId(); searchHits = searchResponse.getHits().getHits();