//////////////////////////

[source,console]
--------------------------------------------------
PUT my-index-000001
{
  "settings": {
    "index.routing.allocation.total_shards_per_node": "1"
  }
}

--------------------------------------------------
// TESTSETUP

[source,console]
--------------------------------------------------
DELETE my-index-000001
--------------------------------------------------
// TEARDOWN

//////////////////////////

// tag::cloud[]
In order to get the shards assigned we'll need to increase the number of shards 
that can be collocated on a node. 
We'll achieve this by inspecting the configuration for the `index.routing.allocation.total_shards_per_node` 
<<indices-get-settings, index setting>> and increasing the configured value for the
indices that have shards unassigned.


**Use {kib}**

//tag::kibana-api-ex[]
. Log in to the {ess-console}[{ecloud} console].
+

. On the **Elasticsearch Service** panel, click the name of your deployment. 
+

NOTE: If the name of your deployment is disabled your {kib} instances might be
unhealthy, in which case please contact https://support.elastic.co[Elastic Support].
If your deployment doesn't include {kib}, all you need to do is 
{cloud}/ec-access-kibana.html[enable it first].

. Open your deployment's side navigation menu (placed under the Elastic logo in the upper left corner)
and go to **Dev Tools > Console**.
+
[role="screenshot"]
image::images/kibana-console.png[{kib} Console,align="center"]

. Inspect the `index.routing.allocation.total_shards_per_node` <<indices-get-settings, index setting>> 
for the index with unassigned shards:
+
[source,console]
----
GET /my-index-000001/_settings/index.routing.allocation.total_shards_per_node?flat_settings
----
+
The response will look like this:
+
[source,console-result]
----
{
  "my-index-000001": {
    "settings": {
      "index.routing.allocation.total_shards_per_node": "1" <1>
    }
  }
}
----
+
<1> Represents the current configured value for the total number of shards
that can reside on one node for the `my-index-000001` index.

. <<indices-update-settings,Increase>> the value for the total number of shards 
that can be assigned on one node to a higher value:
+
[source,console]
----
PUT /my-index-000001/_settings
{
  "index" : {
    "routing.allocation.total_shards_per_node" : "2" <1>
  }
}
----
// TEST[continued]

+
<1> The new value for the `total_shards_per_node` configuration for the `my-index-000001` index
is increased from the previous value of `1` to `2`. 
The `total_shards_per_node` configuration can also be set to `-1`, which 
represents no upper bound with regards to how many shards of the same 
index can reside on one node.

//end::kibana-api-ex[]
// end::cloud[]

// tag::self-managed[]
In order to get the shards assigned you can add more nodes to your {es} cluster 
and assing the index's target tier <<assign-data-tier, node role>> to the new 
nodes. 

To inspect which tier is an index targeting for assignment, use the <<indices-get-settings, get index setting>>
API to retrieve the configured value for the `index.routing.allocation.include._tier_preference`
setting:

[source,console]
----
GET /my-index-000001/_settings/index.routing.allocation.include._tier_preference?flat_settings
----
// TEST[continued]


The response will look like this:

[source,console-result]
----
{
  "my-index-000001": {
    "settings": {
      "index.routing.allocation.include._tier_preference": "data_warm,data_hot" <1>
    }
  }
}
----
// TESTRESPONSE[skip:the result is for illustrating purposes only]


<1> Represents a comma separated list of data tier node roles this index is allowed
to be allocated on, the first one in the list being the one with the higher priority
i.e. the tier the index is targeting.
e.g. in this example the tier preference is `data_warm,data_hot` so the index is
targeting the `warm` tier and more nodes with the `data_warm` role are needed in
the {es} cluster.


Alternatively, if adding more nodes to the {es} cluster is not desired,
inspecting the configuration for the `index.routing.allocation.total_shards_per_node` 
<<indices-get-settings, index setting>> and increasing the configured value will 
allow more shards to be assigned on the same node.

. Inspect the `index.routing.allocation.total_shards_per_node` <<indices-get-settings, index setting>> 
for the index with unassigned shards:
+
[source,console]
----
GET /my-index-000001/_settings/index.routing.allocation.total_shards_per_node?flat_settings
----

+
The response will look like this:

+
[source,console-result]
----
{
  "my-index-000001": {
    "settings": {
      "index.routing.allocation.total_shards_per_node": "1" <1>
    }
  }
}
----

+
<1> Represents the current configured value for the total number of shards
that can reside on one node for the `my-index-000001` index.

. <<indices-update-settings,Increase>> the total number of shards that can be assigned on one node or
reset the value to unbounded (`-1`):
+
[source,console]
----
PUT /my-index-000001/_settings
{
  "index" : {
    "routing.allocation.total_shards_per_node" : -1
  }
}
----
// TEST[continued]

// end::self-managed[]

