
很多情况下,Elasticsearch是需要重建索引的. 比如主分片数量想修改,加了keyword类型等.
*** 作步骤1.首先创建一个新索引,结构一致
PUT /myindex_new
{
"settings": {
"number_of_shards": 2
, "number_of_replicas": 0
},
"mappings": {
"properties": {
"name":{
"type": "keyword"
},
"age":{
"type": "long"
}
}
}
}
2.数据迁移
POST /_reindex?wait_for_completion=false
{
"source": {
"index": "myindex"
},
"dest": {
"index": "myindex_new"
}
}
3.删除老索引
DELETE myindex
3.给新索引加别名
POST _aliases
{
"actions": [
{
"add": {
"index": "myindex_new",
"alias": "myindex"
}
}
]
}
效果
索引名称已经变成myindex_new,为了不影响程序使用,使用别名myindex
name字段改成keyword,已经支持折叠了(collapse)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)