Below code used for get scroll Id.
CODE
SearchRequest searchRequest = new SearchRequest(INDEX);
searchRequest.types(TYPE);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchAllQuery());
searchSourceBuilder.size(2);
searchRequest.source(searchSourceBuilder);
searchRequest.scroll(TimeValue.timeValueMinutes(5L));
SearchResponse searchResponse = null;
try {
searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
e.printStackTrace();
}
String scrollId = searchResponse.getScrollId();
This scroll Id I am passing to UI and again calling getAPI for next records. Below is code:
CODE
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId);
scrollRequest.scroll(new Scroll(TimeValue.timeValueMinutes(5L)));
SearchResponse searchScrollResponse = null;
try {
searchScrollResponse = restHighLevelClient.scroll(scrollRequest, RequestOptions.DEFAULT);
} catch (IOException e1) {
e1.printStackTrace();
}
Getting exception while executing restHighLevelClient.scroll(scrollRequest, RequestOptions.DEFAULT);
Please help how to pass scrollId for second and consecutive request.Preformatted text