# How to retrieve just certain amount of docs from a larger query?

**URL:** https://discuss.elastic.co/t/how-to-retrieve-just-certain-amount-of-docs-from-a-larger-query/17778
**Category:** Elasticsearch
**Created:** [May 28, 2014, 11:42am UTC](https://discuss.elastic.co/t/how-to-retrieve-just-certain-amount-of-docs-from-a-larger-query/17778 "2014-05-28T11:42:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tom\_4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tom_4/32/1045_2.png) [@Tom\_4](https://discuss.elastic.co/u/Tom_4)
#### Post date: [May 28, 2014, 11:42am UTC](https://discuss.elastic.co/t/how-to-retrieve-just-certain-amount-of-docs-from-a-larger-query/17778/1 "2014-05-28T11:42:07Z")

</div>

Hi,

i need to fire a query against larger amount of docs (100.000)  
I just need to get back \_id under a certain soerting and therefore using  
\_source filter false, so there is no overhead by gettings \_source data.  
Nevertheless the response and response processing of course takes a while  
caused by the large amount.

Question: Is there a way to to do something like "execute the query, but  
just give me the 10 docs before and 10 docs after a certain doc identified  
by id" ?

Thx in advance,  
Tom

--  
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/086989ae-5568-4d3c-9c09-a449f4d7a7ce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/086989ae-5568-4d3c-9c09-a449f4d7a7ce%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [May 28, 2014, 1:35pm UTC](https://discuss.elastic.co/t/how-to-retrieve-just-certain-amount-of-docs-from-a-larger-query/17778/2 "2014-05-28T13:35:05Z")

</div>

Look into the scan/scroll query

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

It works like a cursor that iterates through all docs of a query result

Jörg

On Wed, May 28, 2014 at 1:42 PM, Tom [t.oppelt@superreal.de](mailto:t.oppelt@superreal.de) wrote:

> Hi,
> 
> i need to fire a query against larger amount of docs (100.000)  
> I just need to get back \_id under a certain soerting and therefore using  
> \_source filter false, so there is no overhead by gettings \_source data.  
> Nevertheless the response and response processing of course takes a while  
> caused by the large amount.
> 
> Question: Is there a way to to do something like "execute the query, but  
> just give me the 10 docs before and 10 docs after a certain doc identified  
> by id" ?
> 
> Thx in advance,  
> Tom
> 
> --  
> 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/086989ae-5568-4d3c-9c09-a449f4d7a7ce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/086989ae-5568-4d3c-9c09-a449f4d7a7ce%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/086989ae-5568-4d3c-9c09-a449f4d7a7ce%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/086989ae-5568-4d3c-9c09-a449f4d7a7ce%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAKdsXoHW3sr2rrH79XZZH%3D7LQdYMZMo%2BJ93bL53wtEhPajJ81g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHW3sr2rrH79XZZH%3D7LQdYMZMo%2BJ93bL53wtEhPajJ81g%40mail.gmail.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, 1:26am UTC](https://discuss.elastic.co/t/how-to-retrieve-just-certain-amount-of-docs-from-a-larger-query/17778/3 "2017-07-06T01:26:19Z")

</div>


