# Limiting query results

**URL:** <https://discuss.elastic.co/t/limiting-query-results/19278>\
**Category:** Elasticsearch\
**Created:** [August 14, 2014, 8:31am UTC](https://discuss.elastic.co/t/limiting-query-results/19278 "2014-08-14T08:31:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![julie\_dabbs](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@julie\_dabbs](https://discuss.elastic.co/u/julie_dabbs)\
**Post date:** [August 14, 2014, 8:31am UTC](https://discuss.elastic.co/t/limiting-query-results/19278/1 "2014-08-14T08:31:12Z")

</div>

Does anyone know how to execute a query with aggregations and once the  
query is complete only show the top 100 hits in a browser.  
If I use filter limit I am not getting the best results. If I use still am  
displaying a ridiculous total hits back to the user. I am running on  
version  
1.3. Can anyone help

--  
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/4ce06c6d-8a68-42d3-917e-ea4f68521f09%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4ce06c6d-8a68-42d3-917e-ea4f68521f09%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Isabel\_Drost\_Fromm](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@Isabel\_Drost\_Fromm](https://discuss.elastic.co/u/Isabel_Drost_Fromm)\
**Post date:** [August 14, 2014, 9:04am UTC](https://discuss.elastic.co/t/limiting-query-results/19278/2 "2014-08-14T09:04:10Z")

</div>

On Thu, Aug 14, 2014 at 10:31 AM, julie dabbs [julie.e.dabbs@gmail.com](mailto:julie.e.dabbs@gmail.com)  
wrote:

> Does anyone know how to execute a query with aggregations and once the  
> query is complete only show the top 100 hits in a browser.  
> If I use filter limit I am not getting the best results. If I use still am  
> displaying a ridiculous total hits back to the user. I am running on  
> version  
> 1.3. Can anyone help

Not sure if I understood your question correctly. Are you looking for a way  
to implement pagination through results? Then the following might be  
helpful:

> **[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.

Isabel

--  
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/CAFSgB-DpHZ7b\_EqZ3v-xnJdVR8jXbhaHeJ%3D9yrAjLvGR7LfTow%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFSgB-DpHZ7b_EqZ3v-xnJdVR8jXbhaHeJ%3D9yrAjLvGR7LfTow%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![julie\_dabbs](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@julie\_dabbs](https://discuss.elastic.co/u/julie_dabbs)\
**Post date:** [August 14, 2014, 9:59am UTC](https://discuss.elastic.co/t/limiting-query-results/19278/3 "2014-08-14T09:59:52Z")

</div>

No, I have a query with aggregations that can yield thousands of results  
back to the user. I want to only show the top say 200 hits and not this  
huge number but keeping the  
integrity of the data. i.e showing the results with the highest scores

On Thursday, August 14, 2014 10:04:25 AM UTC+1, Isabel Drost-Fromm wrote:

> On Thu, Aug 14, 2014 at 10:31 AM, julie dabbs \<[julie....@gmail.com](mailto:julie....@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Does anyone know how to execute a query with aggregations and once the  
> > query is complete only show the top 100 hits in a browser.  
> > If I use filter limit I am not getting the best results. If I use still  
> > am displaying a ridiculous total hits back to the user. I am running on  
> > version  
> > 1.3. Can anyone help
> 
> Not sure if I understood your question correctly. Are you looking for a  
> way to implement pagination through results? Then the following might be  
> helpful:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-from-size.html#search-request-from-size)
> 
> Isabel

--  
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/b631fa1d-1488-49d3-bcc5-35db67dd6bd4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b631fa1d-1488-49d3-bcc5-35db67dd6bd4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ashish\_Mishra](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@Ashish\_Mishra](https://discuss.elastic.co/u/Ashish_Mishra)\
**Post date:** [August 14, 2014, 10:29am UTC](https://discuss.elastic.co/t/limiting-query-results/19278/4 "2014-08-14T10:29:58Z")

</div>

Use the "size" parameter.

e.g.

$ curl -XGET '[http://localhost:9200/twitter/tweet/\_search](http://localhost:9200/twitter/tweet/_search)' -d '{ "size": "200",  
"aggregations": {  
"my\_agg": {  
"terms": {  
"field": "text"  
}  
}  
}  
}  
'

On Thursday, August 14, 2014 2:59:52 AM UTC-7, julie dabbs wrote:

> No, I have a query with aggregations that can yield thousands of results  
> back to the user. I want to only show the top say 200 hits and not this  
> huge number but keeping the  
> integrity of the data. i.e showing the results with the highest scores
> 
> On Thursday, August 14, 2014 10:04:25 AM UTC+1, Isabel Drost-Fromm wrote:
> 
> > On Thu, Aug 14, 2014 at 10:31 AM, julie dabbs [julie....@gmail.com](mailto:julie....@gmail.com)  
> > wrote:
> > 
> > > Does anyone know how to execute a query with aggregations and once the  
> > > query is complete only show the top 100 hits in a browser.  
> > > If I use filter limit I am not getting the best results. If I use still  
> > > am displaying a ridiculous total hits back to the user. I am running on  
> > > version  
> > > 1.3. Can anyone help
> > 
> > Not sure if I understood your question correctly. Are you looking for a  
> > way to implement pagination through results? Then the following might be  
> > helpful:
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-from-size.html#search-request-from-size)
> > 
> > Isabel

--  
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/ea13194c-c364-47c5-b9db-44066aa2470d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ea13194c-c364-47c5-b9db-44066aa2470d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![julie\_dabbs](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@julie\_dabbs](https://discuss.elastic.co/u/julie_dabbs)\
**Post date:** [August 14, 2014, 2:40pm UTC](https://discuss.elastic.co/t/limiting-query-results/19278/5 "2014-08-14T14:40:11Z")

</div>

Unfortunately this does not change the total of results returned

On Thursday, August 14, 2014 9:31:12 AM UTC+1, julie dabbs wrote:

> Does anyone know how to execute a query with aggregations and once the  
> query is complete only show the top 100 hits in a browser.  
> If I use filter limit I am not getting the best results. If I use still am  
> displaying a ridiculous total hits back to the user. I am running on  
> version  
> 1.3. Can anyone help

--  
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/a8845fd7-5c2a-4853-a168-70e54cece5c5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a8845fd7-5c2a-4853-a168-70e54cece5c5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Isabel\_Drost\_Fromm](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@Isabel\_Drost\_Fromm](https://discuss.elastic.co/u/Isabel_Drost_Fromm)\
**Post date:** [August 14, 2014, 3:08pm UTC](https://discuss.elastic.co/t/limiting-query-results/19278/6 "2014-08-14T15:08:57Z")

</div>

I think an example (trimmed to the relevant parts) of the query you are  
sending, the results you get and the results you expect would help ...

Isabel  
​

--  
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/CAFSgB-C163S%2Bxwan6SP7C1YZJ-LVTSfRfXz\_tb9%2Bd5bS7%2BTvPg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFSgB-C163S%2Bxwan6SP7C1YZJ-LVTSfRfXz_tb9%2Bd5bS7%2BTvPg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ramy](https://avatars.discourse-cdn.com/v4/letter/r/8491ac/32.png) [@Ramy](https://discuss.elastic.co/u/Ramy)\
**Post date:** [August 14, 2014, 3:20pm UTC](https://discuss.elastic.co/t/limiting-query-results/19278/7 "2014-08-14T15:20:38Z")

</div>

Try something like that...

"aggs": {  
"agg\_name": {  
"terms": {  
"field": "my\_field",  
"size": 100  
}  
}  
}

Am Donnerstag, 14. August 2014 16:40:11 UTC+2 schrieb julie dabbs:

> Unfortunately this does not change the total of results returned
> 
> On Thursday, August 14, 2014 9:31:12 AM UTC+1, julie dabbs wrote:
> 
> > Does anyone know how to execute a query with aggregations and once the  
> > query is complete only show the top 100 hits in a browser.  
> > If I use filter limit I am not getting the best results. If I use still  
> > am displaying a ridiculous total hits back to the user. I am running on  
> > version  
> > 1.3. Can anyone help

--  
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/36d438ad-707c-49ed-89fa-37b4643386b7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/36d438ad-707c-49ed-89fa-37b4643386b7%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, 1:08am UTC](https://discuss.elastic.co/t/limiting-query-results/19278/8 "2017-07-06T01:08:31Z")

</div>


