Enable or disable shard allocation
ElasticsearchCluster/NodeCommand
PUT /_cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "primaries"
}
}What it does
Restricts shard allocation cluster-wide (primaries: only primaries are allocated, none: nothing) or returns it to the default (all / null).
When to use it
Before a rolling restart, to prevent unnecessary replica relocations (the officially recommended value is "primaries").
Caution
Remember to revert the setting with null (or "all") afterwards; if it stays restricted, replicas remain unassigned. transient settings are deprecated; use persistent.