Scroll API for java api 2.3.5 Loss of data

Hi !

I am practicing with the java api,When I use scroll to get the data, I get an error that causes

I can't get all the data

**log:**
[2018-06-21 11:30:21,059][DEBUG][action.search            ] [Kiwi Black] [15] Failed to execute query phase
RemoteTransportException[[Kiwi Black][127.0.0.1:9300][indices:data/read/search[phase/scan/scroll]]]; nested: SearchContextMissingException[No search context found for id [15]];
Caused by: SearchContextMissingException[No search context found for id [15]]
	at org.elasticsearch.search.SearchService.findContext(SearchService.java:613)
	at org.elasticsearch.search.SearchService.executeScan(SearchService.java:313)
	at org.elasticsearch.search.action.SearchServiceTransportAction$SearchScanScrollTransportHandler.messageReceived(SearchServiceTransportAction.java:433)
	at org.elasticsearch.search.action.SearchServiceTransportAction$SearchScanScrollTransportHandler.messageReceived(SearchServiceTransportAction.java:430)
	at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
	at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

java code:

SearchRequestBuilder searchRequestBuilder = 
					ESUtil1.getClient().prepareSearch(index).setTypes(type).setSearchType(SearchType.SCAN);
			
			BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
			
			boolQueryBuilder.must(QueryBuilders.termQuery("multi", "test"));
			
			searchRequestBuilder.setQuery(boolQueryBuilder);

			Double pagecount = 1000D;
			
			SearchResponse searchResponse = searchRequestBuilder.setSize(pagecount.intValue()).setScroll(new TimeValue(60000)).execute().actionGet();

			long total=searchResponse.getHits().totalHits();
			
			Double totalpagenum = Math.ceil(Double.valueOf(total)/Double.valueOf(pagecount));
			
			for(int i=0; i<totalpagenum; i++){
				
				searchResponse =ESUtil1.getClient().prepareSearchScroll(searchResponse.getScrollId()).setScroll(new TimeValue(60000)).execute().actionGet();
				
				SearchHit[] searchHists = searchResponse.getHits().getHits();
				
				for (SearchHit hit : searchHists) {
					
				}
			}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.