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.
You can configure an index template or directly configure specific indexes to allocate data to data nodes or cold data nodes.
Procedure: Enable cold data nodes when creating a cluster, and configure an index template or specific index settings to allocate index data storage. The cluster automatically allocates data based on your settings.
Figure 2 Cold data node information

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 an index template or directly configure specific indexes to allocate data to data nodes or cold data nodes.
Configure an index template to allocate indexes to cold or hot data nodes. For example, run the following command to store indexes whose name starts with myindex to cold data nodes. (The command varies slightly depending on the Elasticsearch version.)
PUT _template/test{"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/test{"order": 1,"template": "myindex*","settings": {"index": {"refresh_interval": "30s","number_of_shards": "3","number_of_replicas": "0","routing.allocation.require.box_type": "cold"}}}
Parameter description:
To change the node type for an existing index, run the following command:
PUT myindex/_settings{"index.routing.allocation.require.box_type": "cold"}
Parameter description:
Run the following command to check the distribution of index shards:
GET _cat/shards/myindex?v
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 myindex/_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.