# About setsize Java API

**URL:** <https://discuss.elastic.co/t/about-setsize-java-api/5022>\
**Category:** Elasticsearch\
**Created:** [August 1, 2011, 8:38pm UTC](https://discuss.elastic.co/t/about-setsize-java-api/5022 "2011-08-01T20:38:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kun\_Niu](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@Kun\_Niu](https://discuss.elastic.co/u/Kun_Niu)\
**Post date:** [August 1, 2011, 8:38pm UTC](https://discuss.elastic.co/t/about-setsize-java-api/5022/1 "2011-08-01T20:38:21Z")

</div>

Hi all,  
I don't know if anyone has the same problem or the API is deliberately  
designed like this.  
I have 5 shards and each time I call setSize to get a certain number  
of results, I got 5 times size records back.  
I wonder if there's any way to specify only the number in the setSize  
API as the number of results.

Thanks and best regards,  
Kun

---

<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:** [August 1, 2011, 8:52pm UTC](https://discuss.elastic.co/t/about-setsize-java-api/5022/2 "2011-08-01T20:52:17Z")

</div>

If you are using query\_and\_fetch, thats how it works. You should, 99% of the  
time, use query\_then\_fetch.

On Mon, Aug 1, 2011 at 11:38 PM, Rent a room [haoniukun@gmail.com](mailto:haoniukun@gmail.com) wrote:

> Hi all,  
> I don't know if anyone has the same problem or the API is deliberately  
> designed like this.  
> I have 5 shards and each time I call setSize to get a certain number  
> of results, I got 5 times size records back.  
> I wonder if there's any way to specify only the number in the setSize  
> API as the number of results.
> 
> Thanks and best regards,  
> Kun

---

<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, 3:58am UTC](https://discuss.elastic.co/t/about-setsize-java-api/5022/3 "2017-07-06T03:58:37Z")

</div>


