# Scroll API for java api 2.3.0

**URL:** <https://discuss.elastic.co/t/scroll-api-for-java-api-2-3-0/46342>\
**Category:** Elasticsearch\
**Created:** [April 5, 2016, 7:58am UTC](https://discuss.elastic.co/t/scroll-api-for-java-api-2-3-0/46342 "2016-04-05T07:58:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [April 5, 2016, 7:58am UTC](https://discuss.elastic.co/t/scroll-api-for-java-api-2-3-0/46342/1 "2016-04-05T07:58:57Z")

</div>

Hi !

I am practicing with the java api for elasticsearch and have a question for scroll api.

According to the online document, SearchType.SCAN should be defined for for setSearchType.

[https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search-scrolling.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search-scrolling.html)

SearchResponse scrollResp = client.prepareSearch(test)  
.setSearchType(SearchType.SCAN)  
.setScroll(new TimeValue(60000))  
.setQuery(qb)  
.setSize(100).execute().actionGet(); //100 hits per shard will be returned for each scroll

However, according to the search type page, SearchType SCAN is deprecated from v 2.1.0.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html)

I have checked the code and SCAN is not included in the enum.

> <https://github.com/elastic/elasticsearch/blob/0f00c14afc8428a2a72c0b766d2171029dc8f6e1/core/src/main/java/org/elasticsearch/action/search/SearchType.java>

So, should I keep using the search type SCAN when I use the scroll api? If not , I appreciate if someone can educate me how to call the SearchResponse object for scroll api in correct way.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 5, 2016, 8:53am UTC](https://discuss.elastic.co/t/scroll-api-for-java-api-2-3-0/46342/2 "2016-04-05T08:53:59Z")

</div>

I agree that we should have updated the guide within this change: [https://github.com/elastic/elasticsearch/issues/12994](https://github.com/elastic/elasticsearch/issues/12994)

You can omit `.setSearchType(SearchType.SCAN)` but add a sort on `_doc`. Something similar to:

```auto
{
  "sort": [
    "_doc"
  ]
}

```

Do you want to contribute a documentation change?  
If so, you just have to propose changes for this file: [https://github.com/elastic/elasticsearch/blob/master/docs/java-api/search.asciidoc](https://github.com/elastic/elasticsearch/blob/master/docs/java-api/search.asciidoc)

I'll be happy to merge them.

Thanks for reporting!

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [April 5, 2016, 9:48am UTC](https://discuss.elastic.co/t/scroll-api-for-java-api-2-3-0/46342/3 "2016-04-05T09:48:11Z")

</div>

Hello David.

I would be happy to contribute.

I will make changes in the document.

Thanks,  
Yu

---

<div class="post-metadata">

**Author:** ![nanothermite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nanothermite/32/15956_2.png) [@nanothermite](https://discuss.elastic.co/u/nanothermite)\
**Post date:** [March 2, 2017, 11:10pm UTC](https://discuss.elastic.co/t/scroll-api-for-java-api-2-3-0/46342/4 "2017-03-02T23:10:38Z")

</div>

Would you have the programmatic equivalent of that? Have a very similar use case to port to 5.2.1.

---

<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:** [July 5, 2017, 10:02pm UTC](https://discuss.elastic.co/t/scroll-api-for-java-api-2-3-0/46342/5 "2017-07-05T22:02:39Z")

</div>


