reindex api
reindex 介绍
Reindx API :支持把文档(query 指定文档,不指定则是全部)从一或多个索引(本地或远程)source导入到另外一个索引 dest
- 修改索引的主分片数,修改字段类型,集群内数据迁移/跨集群数据迁移可使用 reindex
reindex api 的注意事项:
- _source必须是 enabled 对于 source index 的所有文档
- reindex 其 dest 无法拷贝 source 索引的settings和mappings,需要自己创建dest 索引再跑reindex
- reindex功能的底层实现原理是通过scroll方式实现的
reindex 支持参数
1.source
- index:指定源数据索引库,支持[]指定多个索引库
- slice:并行化执行reindex操作,自动并行化需要请求后 _reindex?slices=5 增加 slices
- max_docs:reindex 文档的最大数量
- remote:数据源是远程es集群
跨集群 reindex
1. 修改 elasticsearch.yml 增加白名单 并且重启节点:
reindex.remote.whitelist: "otherhost:9200, another:9200, 127.0.10.*:9200, localhost:*"
支持ip,端口号,通配符
2. _reindex 操作
POST _reindex
{
"source":