python - 如何在 Python 中等待 elasticsearch helpers.reindex 完成?
问题描述
我正在重新索引一个大索引,需要删除旧索引才能为新索引添加别名。
helpers.reindex(client=es, source_index=index_old, target_index=index_new, )
# those 2 need to run when reindex finishes
es.indices.delete(index=index_old)
es.indices.put_alias(index=index_new, name=index_old)
问题是最后2个命令需要等待reindex完成,否则会删除原来的索引,不起作用。
我看到 elasticsearch 有 refresh=wait_for 但不是 python helpers.reindex。
什么方法可以使重新索引同步?
解决方案
作为文档统计信息,不推荐使用 helpers.reindex,首选主 API 重新索引。
reindex 方法包含
wait_for_completion
默认为 true 的参数,因此默认情况下Elasticsearch().reindex(...)
是同步的。
推荐阅读
- riscv - RISC-V 中的寄存器使用
- gcc - 目标模式不包含“%”。停止。使用 $(shell sh -c "./ " ) 时(当前工作目录)
- python - 如何使用 autograd.grad 计算 PyTorch 中参数的 Hessian 损失
- javascript - 在 if 条件中丢弃空值的最佳方法是什么 - JavaScript
- linux - GNU Parallel 教程的声明中的“部分记录”是什么意思?
- python - 如何使用 matplotlib 获得稳定的绘图
- ruby-on-rails - 如何在 Rails 中设置 url 路由?
- r - 在不丢失缓存的情况下修改 rmarkdown 块输出?
- tensorflow - 如何将标量输入传递给 tf.keras 模型?
- mysql - 在mysql中导入大量数据时,chunk的重要性是什么?