In an Elasticsearch cluster, switching between hot and cold data storage means to allocate data to nodes of different performance standards based on data temperature (that is, how often data is accessed). The goal is to achieve optimal storage costs and query performance.
If your cluster stores data used for different purposes, such as real-time analytics, log analytics, and monitoring data archives, you can switch between hot and cold storage for specified indexes to balance performance and costs.
Figure 1 How cold/hot storage switchover works

The key is to allocate index data storage by node labels and index allocation policies.
Procedure: Enable cold data nodes, and configure an index template or specific index settings to allocate index data storage. The cluster automatically allocates data based on your settings.
In comparison with data nodes, cold data nodes deliver lower query performance. Determine which type of node to use based on your service needs.
The left part of the console is the command input box, and the triangle icon in its upper-right corner is the execution button. The right part shows the execution result.
You can configure index templates or directly specify index names to allocate specific indexes to data nodes or cold data nodes.
Configure an index template to allocate matching indexes to cold or hot data nodes. For example, run the following command to store newly created indexes whose name starts with myindex to cold data nodes. (The command varies slightly depending on the Elasticsearch version.)
PUT _template/{template_name}{"order": 1,"index_patterns": "myindex*","settings": {"refresh_interval": "30s","number_of_shards": "3","number_of_replicas": "0","routing.allocation.require.box_type": "cold"}}
PUT _template/{template_name}{"order": 1,"template": "myindex*","settings": {"index": {"refresh_interval": "30s","number_of_shards": "3","number_of_replicas": "0","routing.allocation.require.box_type": "cold"}}}
Parameter | Type | Description |
|---|---|---|
index_patterns | String | Defines the index name matching pattern. The wildcard (*) can be used to match multiple indexes. For example, myindex* indicates all indexes whose name starts with myindex. |
routing.allocation.require.box_type | String | Specifies the data node type for shard allocation. The value can be:
If this parameter is not specified, shards will be evenly and randomly distributed among cold and hot data nodes. |
To change the node type for an existing index, run the following command:
PUT {index_name}/_settings{"index.routing.allocation.require.box_type": "cold"}
Parameter | Type | Description |
|---|---|---|
index_name | String | Specifies one or more indexes.
|
routing.allocation.require.box_type | String | Specifies the data node type for shard allocation. The value can be:
If this parameter is not specified, shards will be evenly and randomly distributed among cold and hot data nodes. |
Run the following command to check the distribution of index shards:
When the data volume is large, the switchover may take a long time. There may be an intermediate state where the data of an index resides on both cold data nodes and data nodes.
As shown in the following figure, all shards of the myindex index are stored on the cold data node css-e668-ess-cold-esn-1-1.
index shard prirep state docs store ip nodemyindex 1 p STARTED 14085446 17.8gb 192.168.91.188 css-e668-ess- cold -esn-1-1myindex 2 p STARTED 14094005 17.9gb 192.168.91.188 css-e668-ess- cold -esn-1-1myindex 0 p STARTED 14094742 17.8gb 192.168.91.188 css-e668-ess- cold -esn-1-1
To cancel the cold-hot switchover configuration, run the following command:
PUT {index_name}/_settings{"index.routing.allocation.require.box_type": null}
After the rollback, index data will be evenly and randomly allocated to both cold data nodes and data nodes.