# Is there a way to delete unassigned replica and recover using primary shard for a index?

**URL:** <https://discuss.elastic.co/t/is-there-a-way-to-delete-unassigned-replica-and-recover-using-primary-shard-for-a-index/198160>\
**Category:** Elasticsearch\
**Created:** [September 5, 2019, 6:13am UTC](https://discuss.elastic.co/t/is-there-a-way-to-delete-unassigned-replica-and-recover-using-primary-shard-for-a-index/198160 "2019-09-05T06:13:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![senthilp](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@senthilp](https://discuss.elastic.co/u/senthilp)\
**Post date:** [September 5, 2019, 6:13am UTC](https://discuss.elastic.co/t/is-there-a-way-to-delete-unassigned-replica-and-recover-using-primary-shard-for-a-index/198160/1 "2019-09-05T06:13:03Z")

</div>

One of my replica is failed to recover due to file system issue and Primary shard is fine. Is there a way we can delete only the failed replica for that shard and recover using the Primary shard.

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [September 5, 2019, 8:06am UTC](https://discuss.elastic.co/t/is-there-a-way-to-delete-unassigned-replica-and-recover-using-primary-shard-for-a-index/198160/2 "2019-09-05T08:06:23Z")

</div>

> [@senthilp](#):
>
> Is there a way we can delete only the failed replica for that shard and recover using the Primary shard.

I don't think there is a way to delete just one replica shard but what I've done in similar situations is to remove the replica from the affected index and then add it back, that will force Elasticsearch to create new, fresh replica shards for the primaries.

In that case, just do

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

```

and a few moments later

```
PUT my_index/_settings
{
    "index.number_of_replicas" : 1
}

```

Good luck!

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [September 5, 2019, 8:15am UTC](https://discuss.elastic.co/t/is-there-a-way-to-delete-unassigned-replica-and-recover-using-primary-shard-for-a-index/198160/3 "2019-09-05T08:15:00Z")

</div>

What you ask sounds like the default behaviour: Elasticsearch ignores a failed replica and recovers another replica from the primary by default. I'm curious as to why it's not doing this. Can you share some more information? Logs? Results from the [allocation explain API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html)?

---

<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:** [October 3, 2019, 8:15am UTC](https://discuss.elastic.co/t/is-there-a-way-to-delete-unassigned-replica-and-recover-using-primary-shard-for-a-index/198160/4 "2019-10-03T08:15:00Z")

</div>

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