目标
- 原有索引名:test
- 迁移到新索引:test_new
过程
- 新建索引test_new
-
PUT /mg_short_video_new/ { "settings":{ "index":{ "number_of_shards":"20" } } }
-
- 创建mapping
-
PUT test_new/_mapping/test { "properties": { "filedA": { "type": "text", "analyzer": "ik_smart" } } }
-
- 输入迁移到新索引test_new
-
//size为每批的文档数,官网统计单批次在5-15M时性能最优 POST _reindex?wait_for_completion=false { "source": { "index": "test", "size": 3000 }, "dest": { "index": "test_new" } } 返回taskId:g415R5_KRKu4f_oJxc7JXQ:11594572776
-
- 查看任务进度
-
GET _tasks/g415R5_KRKu4f_oJxc7JXQ:11594572776
-
-
通过任务查看数据迁移完成后,删除旧索引,给新索引起别名为就索引名字
-
//删除旧索引 delete test //新索引起别名 POST _aliases { "actions": [ { "add": { "index": "test_new", "alias": "test" } } ] }
-
-
创建别名短时间内查询报错
-
"type": "es_rejected_execution_exception";原因是部分分片任务较多,拒绝本次查询请求,等待片刻后即可
-
-