# Not able to limit size of result

**URL:** https://discuss.elastic.co/t/not-able-to-limit-size-of-result/3327
**Category:** Elasticsearch
**Created:** [September 12, 2010, 11:57pm UTC](https://discuss.elastic.co/t/not-able-to-limit-size-of-result/3327 "2010-09-12T23:57:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)
#### Post date: [September 12, 2010, 11:57pm UTC](https://discuss.elastic.co/t/not-able-to-limit-size-of-result/3327/1 "2010-09-12T23:57:50Z")

</div>

I am executing the following query, but my result set contains 10 items even  
though I am trying to limit it to 3. Any tips?

{  
"size": 4,  
"query" : {  
"bool" : {  
"must" : {  
"field" : { "mimetype" : "text/html" }  
},  
"must" : {  
"field" : { "locale" : "en" }  
}  
}  
}  
}

Result:

{  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 8,  
"hits" : [{...}]  
}  
}

---

<div class="post-metadata">

### Author: ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)
#### Post date: [September 13, 2010, 9:43am UTC](https://discuss.elastic.co/t/not-able-to-limit-size-of-result/3327/2 "2010-09-13T09:43:32Z")

</div>

Hi,

interesting. Limit on size works quite good for me. Are you able to  
replicate this with curl and some simple testing data?  
BTW: Just to be sure I understand you correctly, you are saying that with  
the json snippets in your email you are getting more then 4 items in the  
hits.hits array?

Regards,  
Lukas

On Mon, Sep 13, 2010 at 1:57 AM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:

> I am executing the following query, but my result set contains 10 items  
> even though I am trying to limit it to 3. Any tips?
> 
> {  
> "size": 4,  
> "query" : {  
> "bool" : {  
> "must" : {  
> "field" : { "mimetype" : "text/html" }  
> },  
> "must" : {  
> "field" : { "locale" : "en" }  
> }  
> }  
> }  
> }
> 
> Result:
> 
> {  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 8,  
> "hits" : [{...}]  
> }  
> }

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [September 13, 2010, 10:00am UTC](https://discuss.elastic.co/t/not-able-to-limit-size-of-result/3327/3 "2010-09-13T10:00:31Z")

</div>

The total marker returns the total hits for the mentioned query across all  
relevant data. The elements in the hits will be bounded by the size  
parameter (except when using search\_type of query\_and\_fetch).

On Mon, Sep 13, 2010 at 11:43 AM, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:

> Hi,
> 
> interesting. Limit on size works quite good for me. Are you able to  
> replicate this with curl and some simple testing data?  
> BTW: Just to be sure I understand you correctly, you are saying that with  
> the json snippets in your email you are getting more then 4 items in the  
> hits.hits array?
> 
> Regards,  
> Lukas
> 
> On Mon, Sep 13, 2010 at 1:57 AM, James Cook [jcook@tracermedia.com](mailto:jcook@tracermedia.com) wrote:
> 
> > I am executing the following query, but my result set contains 10 items  
> > even though I am trying to limit it to 3. Any tips?
> > 
> > {  
> > "size": 4,  
> > "query" : {  
> > "bool" : {  
> > "must" : {  
> > "field" : { "mimetype" : "text/html" }  
> > },  
> > "must" : {  
> > "field" : { "locale" : "en" }  
> > }  
> > }  
> > }  
> > }
> > 
> > Result:
> > 
> > {  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 8,  
> > "hits" : [{...}]  
> > }  
> > }

---

<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, 4:19am UTC](https://discuss.elastic.co/t/not-able-to-limit-size-of-result/3327/4 "2017-07-06T04:19:22Z")

</div>


