# Alternating hits totals for subsequent requests

**URL:** <https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622>\
**Category:** Elasticsearch\
**Created:** [February 5, 2014, 4:27pm UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622 "2014-02-05T16:27:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [February 5, 2014, 4:27pm UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/1 "2014-02-05T16:27:57Z")

</div>

Why would I get a different alternating hits total for subsequent match\_all  
search requests (i.e. curl [http://localhost:9200/\_search](http://localhost:9200/_search)) with zero failed?

i.e. The first time I get 8503251, the next time I get 8479263, the next  
time I get 8503251, the next time I get 8479263, and so on, and so on.

My setup is the following:

- ElasticSearch 0.90.7 with
  - 10 nodes (8 data + 1 primary master + 1 secondary master)
  - 35 indexes w/ 5 shards + 1 replica per index

- CentOS 6.4 (64 bit)
- Java 1.7.0\_45 (64 bit).

Thoughts?

--  
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/93ec8afa-b728-4a6c-a506-288e6259f4ae%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/93ec8afa-b728-4a6c-a506-288e6259f4ae%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 5, 2014, 4:44pm UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/2 "2014-02-05T16:44:16Z")

</div>

It shouldn't happen if you are not performing updates in parallel and don't  
have documents with a TTL. Maybe you have a plugin that persists data in an  
index that is taken into account when summing all hits in all indices?  
(would be helpful to know the index which has changing counts).

On Wed, Feb 5, 2014 at 5:27 PM, asanderson [a.steven.anderson@gmail.com](mailto:a.steven.anderson@gmail.com)wrote:

> Why would I get a different alternating hits total for subsequent  
> match\_all search requests (i.e. curl [http://localhost:9200/\_search](http://localhost:9200/_search)) with  
> zero failed?
> 
> i.e. The first time I get 8503251, the next time I get 8479263, the next  
> time I get 8503251, the next time I get 8479263, and so on, and so on.
> 
> My setup is the following:
> 
> - Elasticsearch 0.90.7 with
> - 10 nodes (8 data + 1 primary master + 1 secondary master)
> - 35 indexes w/ 5 shards + 1 replica per index
> 
> - CentOS 6.4 (64 bit)
> - Java 1.7.0\_45 (64 bit).
> 
> Thoughts?
> 
> --  
> 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/93ec8afa-b728-4a6c-a506-288e6259f4ae%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/93ec8afa-b728-4a6c-a506-288e6259f4ae%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Adrien Grand

--  
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/CAL6Z4j69axbRm31JW-U0-YzMn\_KfWYeFbFy%3DHy-e\_\_6ivQi0GA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j69axbRm31JW-U0-YzMn_KfWYeFbFy%3DHy-e__6ivQi0GA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [February 5, 2014, 4:51pm UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/3 "2014-02-05T16:51:00Z")

</div>

We are definitely not performing any updates in parallel nor do we have any  
TTLs. Even if we did though, why would the counts alternate on subsequent  
requests?

As far as plugins, we are using the analysis-phonetic plugin but  
considering this is a match\_all query, I wouldn't think it would be a  
factor.

How would I determine which index count is different?

On Wednesday, February 5, 2014 11:44:16 AM UTC-5, Adrien Grand wrote:

> It shouldn't happen if you are not performing updates in parallel and  
> don't have documents with a TTL. Maybe you have a plugin that persists data  
> in an index that is taken into account when summing all hits in all  
> indices? (would be helpful to know the index which has changing counts).

--  
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/165f691b-03d5-4913-8949-4e45430d6f8f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/165f691b-03d5-4913-8949-4e45430d6f8f%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 5, 2014, 5:02pm UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/4 "2014-02-05T17:02:20Z")

</div>

Sorry, I thought you said that document counts were changing but it's  
actually more than that it's going back and forth to 2 different values  
(didn't get that).

This is indeed unexpected. You could try to run

curl [http://localhost:9200/\_aliases](http://localhost:9200/_aliases)

to make sure all your shards have the same number of documents (they may  
however have different numbers of deleted documents, this is not a problem).

--  
Adrien Grand

--  
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/CAL6Z4j4jbFksDLVNdBuq393GwF5CttEV-uA\_c-tOpjVBOdP70Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4jbFksDLVNdBuq393GwF5CttEV-uA_c-tOpjVBOdP70Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [February 5, 2014, 5:33pm UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/5 "2014-02-05T17:33:51Z")

</div>

Actually, I did indeed determine that for a few indexes there were  
different doc counts between some shards and their replicas.

Under what circumstances could this happen, and what's the fastest/easiest  
way to correct this situation?

On Wednesday, February 5, 2014 12:02:20 PM UTC-5, Adrien Grand wrote:

> to make sure all your shards have the same number of documents (they may  
> however have different numbers of deleted documents, this is not a problem).

--  
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/31799376-685e-47a0-89f8-e066a86802ef%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/31799376-685e-47a0-89f8-e066a86802ef%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 6, 2014, 9:08am UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/6 "2014-02-06T09:08:44Z")

</div>

On Wed, Feb 5, 2014 at 6:33 PM, asanderson [a.steven.anderson@gmail.com](mailto:a.steven.anderson@gmail.com)wrote:

> Actually, I did indeed determine that for a few indexes there were  
> different doc counts between some shards and their replicas.
> 
> Under what circumstances could this happen, and what's the fastest/easiest  
> way to correct this situation?

This is something that shouldn't happen on a refreshed index. Could you run  
a refresh on the indices that have different counts per shard:

curl -XPOST localhost:9200/${index\_name}/\_refresh

And then show two responses to  
curl [http://localhost:9200/${index\_name}/\_search](http://localhost:9200/$%7Bindex_name%7D/_search)  
that return different counts?

Regarding fixing, the easiest way would be to set the `number_of_replicas`  
setting to 0 and then back to its original value: this will deallocate  
replica shards and then allocate them again and they will get copied from  
the primaries.

--  
Adrien Grand

--  
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/CAL6Z4j4tE%2BOFmvvD%2BCyCHkQLPz8Rnbc-p%3DSQORwU\_0ZPs9Bk2A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4tE%2BOFmvvD%2BCyCHkQLPz8Rnbc-p%3DSQORwU_0ZPs9Bk2A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [February 6, 2014, 3:49pm UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/7 "2014-02-06T15:49:21Z")

</div>

> This is something that shouldn't happen on a refreshed index. Could you  
> run a refresh on the indices that have different counts per shard:
> 
> curl -XPOST localhost:9200/${index\_name}/\_refresh
> 
> And then show two responses to  
> curl [http://localhost:9200/${index\_name}/\_search](http://localhost:9200/$%7Bindex_name%7D/_search)  
> that return different counts?

I did try a refresh via elasticsearch-head but it did not fix the problem  
with the replicas.

> Regarding fixing, the easiest way would be to set the `number_of_replicas`  
> setting to 0 and then back to its original value: this will deallocate  
> replica shards and then allocate them again and they will get copied from  
> the primaries.

I actually fixed it with the cluster move requests but this is good to know  
too.

Thanks for the responses!

--  
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/1a8756d8-6029-4055-b5d9-bcabea59f16e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1a8756d8-6029-4055-b5d9-bcabea59f16e%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![lebowitz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lebowitz/32/1814_2.png) [@lebowitz](https://discuss.elastic.co/u/lebowitz)\
**Post date:** [February 7, 2014, 3:55am UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/8 "2014-02-07T03:55:51Z")

</div>

Take a look at the 'preference' property of the search request body. If you use the user's session id as a custom string, it should prevent the jumping around of values.

Docs: [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-preference.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-preference.html)

Jörg recently mentioned this setting in another thread and I think it applies here.

--  
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/edc22eb9-6476-46be-b102-c643a62c378a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/edc22eb9-6476-46be-b102-c643a62c378a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![asanderson](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@asanderson](https://discuss.elastic.co/u/asanderson)\
**Post date:** [February 7, 2014, 6:32pm UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/9 "2014-02-07T18:32:25Z")

</div>

Take a look at the 'preference' property of the search request body. If

> you use the user's session id as a custom string, it should prevent the  
> jumping around of values.
> 
> Docs:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-preference.html)

Ahh...Good to know. Thank you! 🙂

--  
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/5408ad00-b74e-466b-a11c-becede51edea%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5408ad00-b74e-466b-a11c-becede51edea%40googlegroups.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, 1:51am UTC](https://discuss.elastic.co/t/alternating-hits-totals-for-subsequent-requests/15622/10 "2017-07-06T01:51:40Z")

</div>


