# Why can't I acquire all the search results?

**URL:** https://discuss.elastic.co/t/why-cant-i-acquire-all-the-search-results/11624
**Category:** Elasticsearch
**Created:** [April 18, 2013, 7:29am UTC](https://discuss.elastic.co/t/why-cant-i-acquire-all-the-search-results/11624 "2013-04-18T07:29:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jingang\_Wang](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Jingang\_Wang](https://discuss.elastic.co/u/Jingang_Wang)
#### Post date: [April 18, 2013, 7:29am UTC](https://discuss.elastic.co/t/why-cant-i-acquire-all-the-search-results/11624/1 "2013-04-18T07:29:35Z")

</div>

Hi guys,

I am using ES0.90.0.Beta1 and make search in java api, while I found I  
always could not get the whole search hits set.  
For example, the size of search hits is 824 using prepareCount api, while I  
could only acquire 822 hits using prepareSearch api with the same query.

CountResponse countResponse = client.prepareCount(indexName)  
.setTypes("kba")  
.setQuery(qb)  
.execute()  
.actionGet();

SearchResponse searchResp = client.prepareSearch(indexName)  
.setTypes("kba")  
.setQuery(qb)  
.setFrom(from).setSize(size).setExplain(true)  
.execute()  
.actionGet();

so in my program, after I get the size of search hits using countSearch,  
then I want to acquire all the results using prepareSearch.  
At first, I thought it was caused by the timeout reason, but the problem  
still exist even I set a timeout value for prepareSearch.  
By the way, I am conducting search in an index including three indices all  
with a same alias, would this affect?  
Have anybody encountered this problem before.

--  
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: ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)
#### Post date: [April 18, 2013, 8:25am UTC](https://discuss.elastic.co/t/why-cant-i-acquire-all-the-search-results/11624/2 "2013-04-18T08:25:44Z")

</div>

Hi,

What value did you use as from argument in your search request?  
What is the total hits count for the search request?  
Did the data in your indices change between your count and search request?

A better mechanism to fetch all documents is the use the search type `scan`  
instead of doing a count and several normal search requests:

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

On 18 April 2013 09:29, Jingang Wang [bitwjg@gmail.com](mailto:bitwjg@gmail.com) wrote:

> Hi guys,
> 
> I am using ES0.90.0.Beta1 and make search in java api, while I found I  
> always could not get the whole search hits set.  
> For example, the size of search hits is 824 using prepareCount api, while  
> I could only acquire 822 hits using prepareSearch api with the same query.
> 
> CountResponse countResponse = client.prepareCount(indexName)  
> .setTypes("kba")  
> .setQuery(qb)  
> .execute()  
> .actionGet();
> 
> SearchResponse searchResp = client.prepareSearch(indexName)  
> .setTypes("kba")  
> .setQuery(qb)  
> .setFrom(from).setSize(size).setExplain(true)  
> .execute()  
> .actionGet();
> 
> so in my program, after I get the size of search hits using countSearch,  
> then I want to acquire all the results using prepareSearch.  
> At first, I thought it was caused by the timeout reason, but the problem  
> still exist even I set a timeout value for prepareSearch.  
> By the way, I am conducting search in an index including three indices all  
> with a same alias, would this affect?  
> Have anybody encountered this problem before.
> 
> --  
> 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).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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:40am UTC](https://discuss.elastic.co/t/why-cant-i-acquire-all-the-search-results/11624/3 "2017-07-06T02:40:39Z")

</div>


