user432024
user432024

Reputation: 4665

Inconsistent doc count

Hi I am running Elasticsearch 1.5.2

I indexed 6,761,727 documents in one of my indexes.

When I run the following query....

GET myindex/mytype/_search
{
    "size": 0
}

The hits.total count keeps alternating between 2 values...

"hits": {
    "total": 6761727,
    "max_score": 0,
    "hits": []
}

and

"hits": {
    "total": 6760368,
    "max_score": 0,
    "hits": []
}

No matter how many times I run the query the count goes back and forth between the 2.

I searched around a bit and found out that it seems that primary vs replica shards don't have exact same number of docs. If I use preference=primary then the doc count returned is correct.

What is the easiest way to check which shard is the culprit and try to fix him without re-indexing everything?

Upvotes: 1

Views: 870

Answers (1)

Andrei Stefan
Andrei Stefan

Reputation: 52368

Set the replica count to 0 for that index

PUT /my_index/_settings
{
  "index": {
    "number_of_replicas": 0
  }
}

wait to see no more replicas for that index when you do GET /_cat/shards/my_index?v and then set back to the initial number of replicas.

This will delete all the replicas for that index and then make a new copy of the primaries.

Upvotes: 1

Related Questions