您不必编写类似的代码。周围有一些出色的工具可以帮助您。
只需看看Taskrabbit的elasticdump实用程序,它就能完全满足您的需求。
elasticdump --input=http://localhost:9200/source_index --output=http://localhost:9200/target_index --type=data
最后,由于您使用的是Python,因此您还可以使用elasticsearch-py reindex实用程序

您不必编写类似的代码。周围有一些出色的工具可以帮助您。
只需看看Taskrabbit的elasticdump实用程序,它就能完全满足您的需求。
elasticdump --input=http://localhost:9200/source_index --output=http://localhost:9200/target_index --type=data
最后,由于您使用的是Python,因此您还可以使用elasticsearch-py reindex实用程序