# Java scroll api doesn't match curl scroll

**URL:** <https://discuss.elastic.co/t/java-scroll-api-doesnt-match-curl-scroll/105871>\
**Category:** Elasticsearch\
**Created:** [October 31, 2017, 11:14am UTC](https://discuss.elastic.co/t/java-scroll-api-doesnt-match-curl-scroll/105871 "2017-10-31T11:14:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mm\_guo](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@mm\_guo](https://discuss.elastic.co/u/mm_guo)\
**Post date:** [October 31, 2017, 11:14am UTC](https://discuss.elastic.co/t/java-scroll-api-doesnt-match-curl-scroll/105871/1 "2017-10-31T11:14:09Z")

</div>

I use scroll command to pull data, such as  
`curl localhost:9200/customer/_search?scroll=3m -d '{"size":50,"sort":[{"_doc":{"order":"asc"}}],"query":{"match_all":{}}}'.`  
No matter how many times I executed the command, the scroll \_id didn't change.  
But, when I used the command by java api, the scroll \_id changed. Because I used multi thread to get data by same scrollId, an error occred.

```auto
Caused by: SearchContextMissingException[No search context found for id [180930541]]
	at org.elasticsearch.search.SearchService.findContext(SearchService.java:510)
	at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:286)
	at org.elasticsearch.action.search.SearchTransportService$8.messageReceived(SearchTransportService.java:314)
	at org.elasticsearch.action.search.SearchTransportService$8.messageReceived(SearchTransportService.java:311)
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69)
	at org.elasticsearch.transport.TcpTransport$RequestHandler.doRun(TcpTransport.java:1488)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:596)
	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:

```auto
QueryBuilder qb = matchAllQuery();
 SearchResponse scrollResp = source_client.prepareSearch(index)
                .setScroll(new TimeValue(60000))
                .addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC)
                .setQuery(qb)
                .setSize(5000).get();

```

\*\*:

**Elasticsearch version** (`5.2.0`):

**JVM version** (`1.8`):

**OS version** (Red Hat 4.4.6-3):

someone has any idea?  
thks!

---

<div class="post-metadata">

**Author:** ![mm\_guo](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@mm\_guo](https://discuss.elastic.co/u/mm_guo)\
**Post date:** [November 1, 2017, 7:18am UTC](https://discuss.elastic.co/t/java-scroll-api-doesnt-match-curl-scroll/105871/2 "2017-11-01T07:18:41Z")

</div>

I am sorry, it's an expressed error.  
I mean that after i get a scroll\_id by command  
(curl localhost:9200/customer/\_search?scroll=3m -d '{"size":50,"sort":[{"\_doc":{"order":"asc"}}],"query":{"match\_all":{}}}'),  
next i get the rest result by command(curl 100.110.6.105:9200/\_search/scroll -d '{"scroll":"1m","scroll\_id":"xxxx"}').  
I can get result by same scroll\_id. But this isn't suitable for java API.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 29, 2017, 7:19am UTC](https://discuss.elastic.co/t/java-scroll-api-doesnt-match-curl-scroll/105871/3 "2017-11-29T07:19:06Z")

</div>

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