You need to enable JavaScript to run this app.
文档中心
云搜索服务

云搜索服务

复制全文
下载 pdf
索引管理
Reindex 与 Split Index 使用指南
复制全文
下载 pdf
Reindex 与 Split Index 使用指南
本文介绍如何在 Elasticsearch 和 OpenSearch 实例中使用 Reindex 和 Split Index。​
方案对比​
​
对比项​
Reindex​
Split Index​
主要场景​
同实例或跨实例修改/同步数据。​
同实例调整索引分片。​
跨实例​
支持。​
不支持,仅支持同实例。​
按条件同步​
支持,可基于查询条件同步部分数据。​
不支持。​
修改数据内容​
支持。​
不支持。​
数据同步方式​
逐个文档读取写入。​
基于底层文件复制。​
执行效率​
大数据量(≥ 5000 万/亿级文档)时耗时较长。​
执行效率较高。​
​
注意事项​
Reindex​
如果业务仍有写入,需要处理增量数据,避免数据遗漏。​
Split Index​
  • 执行 Split Index 前必须停止业务写入。​
  • 验证新索引数据无误后,再切换业务访问到新索引。​
使用方法​
Reindex​
  1. 执行以下命令,将源索引中的数据同步到目标索引。​
  • ​
    POST _reindex?wait_for_completion=false​
    {​
    "source": {​
    "index": "source_index_name",​
    "size": 1000​
    },​
    "dest": {​
    "index": "dest_index_name"​
    }​
    }​
    ​
  • 命令中参数说明如下表所示。​
  • ​
    参数​
    说明​
    wait_for_completion​
    设置为 false 时,Reindex 以异步方式执行,并返回任务 ID。​
    source.index​
    源索引名称。​
    source.size​
    每批处理的文档数量,默认为 1000。​
    dest.index​
    目标索引名称。​
    ​
  1. 执行以下命令,根据返回的任务 ID 查询 Reindex 执行进度。​
  • ​
    GET _tasks/{task_id}​
    ​
Split Index​
  1. 执行 Split Index 前,需要执行以下命令将阻塞源索引写入。​
  • ​
    PUT ${old_index}/_settings​
    {​
    "index.blocks.write": true​
    }​
    ​
  1. 执行以下命令,将源索引拆分为新的索引。​
  • ​
    POST ${old_index}/_split/${new_index}​
    {​
    "settings": {​
    "index.number_of_shards": ${2*previous_shards},​
    "index.number_of_replicas": 0​
    }​
    }​
    ​
  • 命令中参数说明如下表所示。​
  • ​
    参数​
    说明​
    index.number_of_shards​
    新索引分片数。建议设置为源索引分片数的 2 倍,否则可能带来存储和 CPU 风险。​
    index.number_of_replicas​
    源索引名称。​
    ​
说明​
Split Index 执行过程中,请求将返回超时,但后台任务仍会继续执行,可忽略该超时信息。​
最近更新时间:2026.08.04 15:36:16
这个页面对您有帮助吗?
有用
有用
无用
无用