我们正在尝试使用以下无痛脚本来重新索引 Elasticsearch 中的数据。
POST _reindex
{
"source": {
"index": "metricbeat-*"
},
"dest": {
"index": "metricbeat"
},
"script": {
"lang": "painless",
"inline": "ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'"
}
}
Run Code Online (Sandbox Code Playgroud)
该脚本运行完美,并创建了我们所有索引的另一个副本。exa:如果我在运行此脚本后将原始索引设置为 metricbeat-2016.05.30,它将创建 metricbeat-2016.05.30-1,它是原始索引的精确副本,即 (metricbeat-2016.05.30)
现在我想做以下两件事:
1] 删除原始索引,即 metricbeat-2016.05.30
2] 将重新索引的索引或原始索引的副本(即(metricbeat-2016.05.30-1))重命名为 metricbeat-2016.05.30,即原始索引。
我们应该怎么做 ?我们可以修改上面的无痛脚本吗?
提前致谢 !