# Reindex corrupted index into a new copy

**URL:** <https://discuss.elastic.co/t/reindex-corrupted-index-into-a-new-copy/330765>\
**Category:** Elasticsearch\
**Tags:** reindex\
**Created:** [April 25, 2023, 6:41pm UTC](https://discuss.elastic.co/t/reindex-corrupted-index-into-a-new-copy/330765 "2023-04-25T18:41:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rivermigue](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@rivermigue](https://discuss.elastic.co/u/rivermigue)\
**Post date:** [April 25, 2023, 6:41pm UTC](https://discuss.elastic.co/t/reindex-corrupted-index-into-a-new-copy/330765/1 "2023-04-25T18:41:52Z")

</div>

Hello,

Is it possible to reindex a corrupted index into a new copy accepting some data loss?  
I am trying to reindex a corrupted index with the following call:

```auto
POST _reindex
{
 "source": {
   "index": "index001"
 },
 "dest": {
   "index": "index001-copy"
 }
}

```

However, when I do so, I receive the following error message:  
`Search rejected due to missing shards [[index001][1]]. Consider using 'allow_partial_search_results' setting to bypass this error.`

\_reindex call doesnt accept the setting `allow_partial_search_results` so I tried to setup the cluster with a default value which didn't help either as it keeps showing the same reindex error message, the default cluster setting I modified is:

```auto
PUT _cluster/settings
{
    "persistent" : {
        "search.default_allow_partial_results" : true
    }
}

```

The primary shard has a replica shard that hasn't been assigned to a node since its primary is corrupted, if reindex is not an option, can the replica be promoted as primary?

Elasticsearch version is 7.16.3 running under CentOS 7.

Thank you,

---

<div class="post-metadata">

**Author:** ![rivermigue](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@rivermigue](https://discuss.elastic.co/u/rivermigue)\
**Post date:** [May 1, 2023, 4:02pm UTC](https://discuss.elastic.co/t/reindex-corrupted-index-into-a-new-copy/330765/2 "2023-05-01T16:02:50Z")

</div>

Does anyone know what to do in this case?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 1, 2023, 4:12pm UTC](https://discuss.elastic.co/t/reindex-corrupted-index-into-a-new-copy/330765/3 "2023-05-01T16:12:59Z")

</div>

If you had a valid replica that would have been promoted to primary once the primary got corrupted. You therefore probably have lost the data in that shard. How many primary shards does the index have?

I believe you can use the [cluster reroute API](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/cluster-reroute.html) to force allocate the missing shard. It has options `allocate_stale_primary` and `allocate_empty_primary` to force allocation, but this may lead to some or all data held on that shard to be lost. The appropriate one to use depends on the exact status of the index.

---

<div class="post-metadata">

**Author:** ![rivermigue](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@rivermigue](https://discuss.elastic.co/u/rivermigue)\
**Post date:** [May 1, 2023, 4:47pm UTC](https://discuss.elastic.co/t/reindex-corrupted-index-into-a-new-copy/330765/4 "2023-05-01T16:47:29Z")

</div>

The index has 8 primaries and 8 replicas, I will take a look at the cluster reroute api documentation and see if that fits.  
Thank you for your answer.

---

<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 29, 2023, 4:48pm UTC](https://discuss.elastic.co/t/reindex-corrupted-index-into-a-new-copy/330765/5 "2023-05-29T16:48:27Z")

</div>

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