# Primary and Replica shards are giving different results for same query

**URL:** <https://discuss.elastic.co/t/primary-and-replica-shards-are-giving-different-results-for-same-query/178431>\
**Category:** Elasticsearch\
**Created:** [April 25, 2019, 10:39am UTC](https://discuss.elastic.co/t/primary-and-replica-shards-are-giving-different-results-for-same-query/178431 "2019-04-25T10:39:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sangam0707](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@sangam0707](https://discuss.elastic.co/u/sangam0707)\
**Post date:** [April 25, 2019, 10:39am UTC](https://discuss.elastic.co/t/primary-and-replica-shards-are-giving-different-results-for-same-query/178431/1 "2019-04-25T10:39:43Z")

</div>

I am getting inconsistent results for some queries.  
For same query , primary and replica shards are giving different number of documents.

I have 8 primary shards and 8 replica shards on 2 datanodes.  
I am using routing to store and search the data.

To resolve the issue ,I deleted all the shards on one datanode. It solved the problem for some queries but some are still not resolved.  
Using preference solves the consistency problem, but does not solve the root cause.

Elasticsearch version used 6.6.2.  
\_cat/shards output  
**index shard prirep state docs store node**  
xyz 5 r STARTED 615773 1.3gb es-data-02  
xyz 5 p STARTED 615773 1.3gb es-data-01  
xyz 3 r STARTED 1882378 3.9gb es-data-02  
xyz 3 p STARTED 1882378 3.9gb es-data-01  
xyz 7 p STARTED 20228845 38.8gb es-data-02  
xyz 7 r STARTED 20228845 38.8gb es-data-01  
xyz 2 p STARTED 15240307 33.8gb es-data-02  
xyz 2 r STARTED 15240307 33.6gb es-data-01  
xyz 4 p STARTED 8641729 13.8gb es-data-02  
xyz 4 r STARTED 8641729 13.8gb es-data-01  
xyz 1 r STARTED 55786281 **138.1gb** es-data-02  
xyz 1 p STARTED 55786281 **138.1gb** es-data-01  
xyz 6 p STARTED 3788092 6.5gb es-data-02  
xyz 6 r STARTED 3788092 6.5gb es-data-01  
xyz 0 r STARTED 1557571 2.6gb es-data-02  
xyz 0 p STARTED 1557571 2.6gb es-data-01

This issue is happening for shard 1.  
I want to know, what can be the root cause for this?  
How we can avoid this behavior?

---

<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:** [May 23, 2019, 10:39am UTC](https://discuss.elastic.co/t/primary-and-replica-shards-are-giving-different-results-for-same-query/178431/2 "2019-05-23T10:39:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
