# Why Cluster Allocation Explain API explains the allocation of the first unassigned shard?

**URL:** <https://discuss.elastic.co/t/why-cluster-allocation-explain-api-explains-the-allocation-of-the-first-unassigned-shard/162199>\
**Category:** Elasticsearch\
**Created:** [December 27, 2018, 5:52am UTC](https://discuss.elastic.co/t/why-cluster-allocation-explain-api-explains-the-allocation-of-the-first-unassigned-shard/162199 "2018-12-27T05:52:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhil.k](https://avatars.discourse-cdn.com/v4/letter/n/5daacb/32.png) [@nikhil.k](https://discuss.elastic.co/u/nikhil.k)\
**Post date:** [December 27, 2018, 5:52am UTC](https://discuss.elastic.co/t/why-cluster-allocation-explain-api-explains-the-allocation-of-the-first-unassigned-shard/162199/1 "2018-12-27T05:52:41Z")

</div>

Hi All,

Elasticsearch Version - 5.4.3

I have a cluster of only one node. I have created an index by using the following command:

# curl -X PUT "node1:9200/index10" -H 'Content-Type: application/json' -d'

{  
"settings" : {  
"index" : {  
"number\_of\_shards" : 5,  
"number\_of\_replicas" : 1  
}  
}  
}'

When I use the cat shards API command following is the output:  
[root@node1 ~]# curl -X GET "node1:9200/\_cat/shards"?v  
index shard prirep state docs store ip node  
index10 2 p STARTED 0 130b 10.0.4.67 node1  
index10 2 r UNASSIGNED  
index10 1 p STARTED 0 130b 10.0.4.67 node1  
index10 1 r UNASSIGNED  
index10 4 p STARTED 0 130b 10.0.4.67 node1  
index10 4 r UNASSIGNED  
index10 3 p STARTED 0 130b 10.0.4.67 node1  
index10 3 r UNASSIGNED  
index10 0 p STARTED 0 130b 10.0.4.67 node1  
index10 0 r UNASSIGNED

It has "5" replicas shards in the "UNASSIGNED" state in the cluster. When cluster allocation explain API command is used following is the output:

[root@node1 ~]# curl -X GET "node1:9200/\_cluster/allocation/explain"  
{"index":"index10","shard":2,"primary":false,"current\_state":"unassigned","unassigned\_info":{"reason":"INDEX\_CREATED","at":"2018-12-27T05:24:01.835Z","last\_allocation\_status":"no\_attempt"},"can\_allocate":"no","allocate\_explanation":"cannot allocate because allocation is not permitted to any of the nodes","node\_allocation\_decisions":[{"node\_id":"TRq-P0CKS5K0oZWFLIaBIA","node\_name":"node1","transport\_address":"10.0.4.67:9300","node\_decision":"no","weight\_ranking":1,"deciders":[{"decider":"same\_shard","decision":"NO","explanation":"the shard cannot be allocated to the same node on which a copy of the shard already exists [[index10][2], node[TRq-P0CKS5K0oZWFLIaBIA], [P], s[STARTED], a[id=Hoist8tzT-W9y4VF0VOyHw]]"}]}]}[root@node1 ~]#

Explanation for only "UNASSIGNED" shard "2" is returned.

> Instead, the explanation for every "UNASSIGNED" shard should have been returned here. What do you all think about it??

Regards  
Nikhil Kapoor

---

<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:** [December 27, 2018, 8:47am UTC](https://discuss.elastic.co/t/why-cluster-allocation-explain-api-explains-the-allocation-of-the-first-unassigned-shard/162199/2 "2018-12-27T08:47:09Z")

</div>

> [@nikhil.k](#):
>
> > Instead, the explanation for every "UNASSIGNED" shard should have been returned here. What do you all think about it??

The basic `GET _cluster/allocation/explain` API is intended to give a quick hint about why the cluster is not reporting `green` health, for which it is sufficient to describe any unassigned shard. It is quite common that there are many shards that are all unassigned for the same reason, and can all be fixed with one change. This is the case in your situation: since you only have one node no replicas can be assigned, and all unassigned shards will be reporting `the shard cannot be allocated to the same node on which a copy of the shard already exists`. Reporting all unassigned shards in this situation would be overwhelming and unhelpful.

If you want to diagnose a particular shard, you should use the more specific API:

```plaintext
GET /_cluster/allocation/explain
{
  "index": "myindex",
  "shard": 0,
  "primary": true
}

```

---

<div class="post-metadata">

**Author:** ![nikhil.k](https://avatars.discourse-cdn.com/v4/letter/n/5daacb/32.png) [@nikhil.k](https://discuss.elastic.co/u/nikhil.k)\
**Post date:** [December 27, 2018, 9:16am UTC](https://discuss.elastic.co/t/why-cluster-allocation-explain-api-explains-the-allocation-of-the-first-unassigned-shard/162199/3 "2018-12-27T09:16:46Z")

</div>

Thanks @DavidTurner for the reply. I understood your point.

Regards  
Nikhil Kapoor

---

<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:** [January 24, 2019, 9:16am UTC](https://discuss.elastic.co/t/why-cluster-allocation-explain-api-explains-the-allocation-of-the-first-unassigned-shard/162199/4 "2019-01-24T09:16:50Z")

</div>

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