Allocate

edit

Phases allowed: warm, cold.

Updates the index settings to change which nodes are allowed to host the index shards and change the number of replicas.

The allocate action is not allowed in the hot phase. The initial allocation for the index must be done manually or via index templates.

You can configure this action to modify both the allocation rules and number of replicas, only the allocation rules, or only the number of replicas. For more information about how Elasticsearch uses replicas for scaling, see Scalability and resilience. See Index-level shard allocation filtering for more information about controlling where Elasticsearch allocates shards of a particular index.

Options

edit

You must specify the number of replicas or at least one include, exclude, or require option. An empty allocate action is invalid.

For more information about using custom attributes for shard allocation, see Index-level shard allocation filtering.

number_of_replicas
(Optional, integer) Number of replicas to assign to the index.
include
(Optional, object) Assigns an index to nodes that have at least one of the specified custom attributes.
exclude
(Optional, object) Assigns an index to nodes that have none of the specified custom attributes.
require
(Optional, object) Assigns an index to nodes that have all of the specified custom attributes.

Example

edit

The allocate action in the following policy changes the index’s number of replicas to 2. The index allocation rules are not changed.

PUT _ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "warm": {
        "actions": {
          "allocate" : {
            "number_of_replicas" : 2
          }
        }
      }
    }
  }
}

Assign index to nodes using a custom attribute

edit

The allocate action in the following policy assigns the index to nodes that have a box_type of hot or warm.

To designate a node’s box_type, you set a custom attribute in the node configuration. For example, set node.attr.box_type: hot in elasticsearch.yml. For more information, see Enabling index-level shard allocation filtering.

PUT _ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "warm": {
        "actions": {
          "allocate" : {
            "include" : {
              "box_type": "hot,warm"
            }
          }
        }
      }
    }
  }
}

Assign index to a specific node and update replica settings

edit

The allocate action in the following policy updates the index to have one replica per shard and be allocated to nodes that have a box_type of cold.

To designate a node’s box_type, you set a custom attribute in the node configuration. For example, set node.attr.box_type: cold in elasticsearch.yml. For more information, see Enabling index-level shard allocation filtering.

PUT _ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "warm": {
        "actions": {
          "allocate" : {
            "number_of_replicas": 1,
            "require" : {
              "box_type": "cold"
            }
        }
        }
      }
    }
  }
}