# How can I delete unnassigned shards?

**URL:** <https://discuss.elastic.co/t/how-can-i-delete-unnassigned-shards/327433>\
**Category:** Elasticsearch\
**Created:** [March 10, 2023, 9:55am UTC](https://discuss.elastic.co/t/how-can-i-delete-unnassigned-shards/327433 "2023-03-10T09:55:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![frankmehlhop.com](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@frankmehlhop.com](https://discuss.elastic.co/u/frankmehlhop.com)\
**Post date:** [March 10, 2023, 9:55am UTC](https://discuss.elastic.co/t/how-can-i-delete-unnassigned-shards/327433/1 "2023-03-10T09:55:21Z")

</div>

In my cluster there are unassigned shards which are not primary shards.  
I don't know why I have these secondary shards in my cluster. I didn't create them intentionally and I use the default configuration (elasticsearch.yml). How can I delete these unnassigned shards? (without deleting the primary shard)

```auto
GET _cluster/allocation/explain?pretty
{
  "index": "0001.metadata",
  "shard": 0,
  "primary": false
}

```

```auto
{
  "index" : "0001.metadata",
  "shard" : 0,
  "primary" : false,
  "current_state" : "unassigned",
  "unassigned_info" : {
    "reason" : "CLUSTER_RECOVERED",
    "at" : "2023-03-10T07:22:54.916Z",
    "last_allocation_status" : "no_attempt"
  },
  "can_allocate" : "no",
  "allocate_explanation" : "Elasticsearch isn't allowed to allocate this shard to any of the nodes in the cluster. Choose a node to which you expect this shard to be allocated, find this node in the node-by-node explanation, and address the reasons which prevent Elasticsearch from allocating this shard there.",
  "node_allocation_decisions" : [
    {
      "node_id" : "4S9PhH2FQymVIe3tysYpww",
      "node_name" : "FM11L",
      "transport_address" : "127.0.0.1:9300",
      "node_attributes" : {
        "ml.max_jvm_size" : "17037262848",
        "xpack.installed" : "true",
        "ml.machine_memory" : "34069057536"
      },
      "node_decision" : "no",
      "deciders" : [
        {
          "decider" : "same_shard",
          "decision" : "NO",
          "explanation" : "a copy of this shard is already allocated to this node [[0001.metadata][0], node[4S9PhH2FQymVIe3tysYpww], [P], s[STARTED], a[id=e6Kbv9aSQt6LaHlnf023sg]]"
        }
      ]
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![frankmehlhop.com](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@frankmehlhop.com](https://discuss.elastic.co/u/frankmehlhop.com)\
**Post date:** [March 10, 2023, 10:56am UTC](https://discuss.elastic.co/t/how-can-i-delete-unnassigned-shards/327433/2 "2023-03-10T10:56:03Z")

</div>

I found a solution for my problem.

I set

```auto
PUT _settings
{
  "index.number_of_replicas": 0
}

```

And so I got the health status green.

Also I find  
[https://www.cyberithub.com/how-to-delete-elasticsearch-unassigned-shards/](https://www.cyberithub.com/how-to-delete-elasticsearch-unassigned-shards/)

---

<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:** [April 7, 2023, 10:57am UTC](https://discuss.elastic.co/t/how-can-i-delete-unnassigned-shards/327433/3 "2023-04-07T10:57:02Z")

</div>

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