# Sorting in scroll API

**URL:** <https://discuss.elastic.co/t/sorting-in-scroll-api/65344>\
**Category:** Elasticsearch\
**Created:** [November 8, 2016, 11:54am UTC](https://discuss.elastic.co/t/sorting-in-scroll-api/65344 "2016-11-08T11:54:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bharath\_meka](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bharath\_meka](https://discuss.elastic.co/u/bharath_meka)\
**Post date:** [November 8, 2016, 11:54am UTC](https://discuss.elastic.co/t/sorting-in-scroll-api/65344/1 "2016-11-08T11:54:04Z")

</div>

Hi,

We are using scroll API (Elastic Search 2.x) to retrieve large number of records. Though we are able to retrieve the logs the sorting seems to be an issue. We have specified sort in the query but still see the logs jumbled over. Is this an expected behavior?

Regards,  
Bharath

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 8, 2016, 12:24pm UTC](https://discuss.elastic.co/t/sorting-in-scroll-api/65344/2 "2016-11-08T12:24:30Z")

</div>

I believe that sorting isn't supported with the deprecated `scan` search type (search [this](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-request-search-type.html) page for `scan`). In the middle 2.x versions Elasticsearch introduced sorting by `_doc` to get the performance of `scan`without a different search type. Anyway, if you don't use `scan` then `scroll` should support sorting without trouble.

---

<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:** [December 6, 2016, 12:24pm UTC](https://discuss.elastic.co/t/sorting-in-scroll-api/65344/3 "2016-12-06T12:24:40Z")

</div>

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