# Does Scan API support doc key sort order

**URL:** <https://discuss.elastic.co/t/does-scan-api-support-doc-key-sort-order/16109>\
**Category:** Elasticsearch\
**Created:** [March 3, 2014, 2:35pm UTC](https://discuss.elastic.co/t/does-scan-api-support-doc-key-sort-order/16109 "2014-03-03T14:35:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![roytmana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roytmana/32/44855_2.png) [@roytmana](https://discuss.elastic.co/u/roytmana)\
**Post date:** [March 3, 2014, 2:35pm UTC](https://discuss.elastic.co/t/does-scan-api-support-doc-key-sort-order/16109/1 "2014-03-03T14:35:08Z")

</div>

Hello,

I need to compare ES with source data and I would like to do it in one pass  
if possible which means I need to pull my data from ES in the doc key  
order.  
Is it possible to do it with SCAN API or scan order is undefined (based on  
how it is stored in lucene segments?)

thank you,  
Alex

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/058dbe1a-2e17-487a-b31a-0dc4b8112d22%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/058dbe1a-2e17-487a-b31a-0dc4b8112d22%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)\
**Post date:** [March 4, 2014, 11:59am UTC](https://discuss.elastic.co/t/does-scan-api-support-doc-key-sort-order/16109/2 "2014-03-04T11:59:08Z")

</div>

Hi Alex,

The Scan API indeed works based on the order of documents in the lucene  
segments. This is the most efficient way to get bulks of data which is the  
intended use case of this API.

Once 1.1 is released you'd be able to efficiently scroll while maintaining  
order (see this  
issue: [Improve scroll search by using Lucene's IndexSearcher#searchAfter(...) · Issue #4940 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/4940) )

Cheers,  
Boaz

On Monday, March 3, 2014 3:35:08 PM UTC+1, AlexR wrote:

> Hello,
> 
> I need to compare ES with source data and I would like to do it in one  
> pass if possible which means I need to pull my data from ES in the doc key  
> order.  
> Is it possible to do it with SCAN API or scan order is undefined (based  
> on how it is stored in lucene segments?)
> 
> thank you,  
> Alex

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fb70812e-298a-4b74-b1f5-4c3c38e18adc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fb70812e-298a-4b74-b1f5-4c3c38e18adc%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 1:45am UTC](https://discuss.elastic.co/t/does-scan-api-support-doc-key-sort-order/16109/3 "2017-07-06T01:45:51Z")

</div>


