The purpose of the cluster allocation explain API is to provide
explanations for shard allocations in the cluster. For unassigned shards,
the explain API provides an explanation for why the shard is unassigned.
For assigned shards, the explain API provides an explanation for why the
shard is remaining on its current node and has not moved or rebalanced to
another node. This API can be very useful when attempting to diagnose why
a shard is unassigned or why a shard continues to remain on its current node
when you might expect otherwise.

Specify the index and shard id of the shard you would like an explanation
for, as well as the primary flag to indicate whether to explain the primary
shard for the given shard id or one of its replica shards. These three request
parameters are required.

You may also specify an optional current_node request parameter to only explain
a shard that is currently located on current_node. The current_node can be
specified as either the node id or node name.

An explanation as to why the decider returned a no decision, with a helpful hint pointing to the setting that led to the decision

You can return information gathered by the cluster info service about disk usage
and shard sizes by setting the include_disk_info parameter to true:

GET /_cluster/allocation/explain?include_disk_info=true

Additionally, if you would like to include all decisions that were factored into the final
decision, the include_yes_decisions parameter will return all decisions for each node:

GET /_cluster/allocation/explain?include_yes_decisions=true

The default value for include_yes_decisions is false, which will only
include the no decisions in the response. This is generally what you would
want, as the no decisions indicate why a shard is unassigned or cannot be moved,
and including all decisions include the yes ones adds a lot of verbosity to the
API’s response output.

The API response output for an unassigned primary shard that had previously been
allocated to a node in the cluster: