# Restrict query result size when using scan and scroll API

**URL:** <https://discuss.elastic.co/t/restrict-query-result-size-when-using-scan-and-scroll-api/21351>\
**Category:** Elasticsearch\
**Created:** [December 22, 2014, 12:06pm UTC](https://discuss.elastic.co/t/restrict-query-result-size-when-using-scan-and-scroll-api/21351 "2014-12-22T12:06:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay\_Divakaran](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@Ajay\_Divakaran](https://discuss.elastic.co/u/Ajay_Divakaran)\
**Post date:** [December 22, 2014, 12:06pm UTC](https://discuss.elastic.co/t/restrict-query-result-size-when-using-scan-and-scroll-api/21351/1 "2014-12-22T12:06:00Z")

</div>

Hi all,

I'm using ES 0.90.13.

The below query is what I use for the scan and scroll operation.

GET  
_url:_  
/index-name/document-type/\_search?search\_type=scan&scroll=5m&timeout=3m&size=4000  
_body:_  
{"sort": ["date\_value"], "query": {"term": {"field1": false}}, "from": 0,  
"size": 10000}

My requirement is to restrict the result-set (different from the scroll  
batch size). How do I achieve this?  
Is there a way to remove the batch-size and result set ambiguity?

--  
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/34c2df92-85cf-4909-b6a3-96061835b146%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/34c2df92-85cf-4909-b6a3-96061835b146%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:42am UTC](https://discuss.elastic.co/t/restrict-query-result-size-when-using-scan-and-scroll-api/21351/2 "2017-07-06T00:42:22Z")

</div>


