# Limit removes items from the top

**URL:** <https://discuss.elastic.co/t/limit-removes-items-from-the-top/14542>\
**Category:** Elasticsearch\
**Created:** [November 22, 2013, 10:41am UTC](https://discuss.elastic.co/t/limit-removes-items-from-the-top/14542 "2013-11-22T10:41:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)\
**Post date:** [November 22, 2013, 10:41am UTC](https://discuss.elastic.co/t/limit-removes-items-from-the-top/14542/1 "2013-11-22T10:41:19Z")

</div>

when i query without limit i get 6 result as

tution: 16512  
tution: 17632  
tution: 17822  
tution: 17870  
tution: 19683  
tution: 19838

when i add limit like in the query below the 1st element is lost , limit  
should remove the last element

{  
"query": {  
"filtered": {  
"query": {  
"match": {  
"programs": "computer science"  
}  
},  
"filter": {  
"and": [  
{  
"limit": {  
"value": 5  
}  
},  
{  
"range": {  
"tution": {  
"from": 10000,  
"to": 20000  
}  
}  
}  
]  
}  
}  
},  
"sort": [  
{  
"tution": {  
"order": "asc"  
}  
}  
]  
}

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 22, 2013, 7:52pm UTC](https://discuss.elastic.co/t/limit-removes-items-from-the-top/14542/2 "2013-11-22T19:52:15Z")

</div>

Have you looked into using the size parameter of the query? Much simpler  
solution.

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

I never used the limit filter, but it looks more useful for doing  
statistics on a limited subsection of the index.

Cheers,

Ivan

On Fri, Nov 22, 2013 at 2:41 AM, paul [avinashpaul85@gmail.com](mailto:avinashpaul85@gmail.com) wrote:

> when i query without limit i get 6 result as
> 
> tution: 16512  
> tution: 17632  
> tution: 17822  
> tution: 17870  
> tution: 19683  
> tution: 19838
> 
> when i add limit like in the query below the 1st element is lost , limit  
> should remove the last element
> 
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "match": {  
> "programs": "computer science"  
> }  
> },  
> "filter": {  
> "and": [  
> {  
> "limit": {  
> "value": 5  
> }  
> },  
> {  
> "range": {  
> "tution": {  
> "from": 10000,  
> "to": 20000  
> }  
> }  
> }  
> ]  
> }  
> }  
> },  
> "sort": [  
> {  
> "tution": {  
> "order": "asc"  
> }  
> }  
> ]  
> }
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
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, 2:05am UTC](https://discuss.elastic.co/t/limit-removes-items-from-the-top/14542/3 "2017-07-06T02:05:15Z")

</div>


