[英]Ignore indexing existing document while reindexing in ElasticSearch
我正在尝试在两个 ElasticSearch 实例之间移动数据。有没有办法跳过目标索引中已经存在的文档?
from opensearchpy import OpenSearch,RequestsHttpConnection, helpers
def reindex_data_to_data_curation_es(es_src, es_des):
try:
helpers.reindex(es_src, src_idx, tar_idx, target_client=es_des, query={'query': {'match_all': {}}})
except Exception as e:
print("timed out", str(e))
您不能从源索引中跳过它们,但您不能确保在目标索引中不覆盖它们(如果它们已经存在)。 只需添加op_type: create
设置,以便不覆盖目标索引中的现有文档:
helpers.reindex(es_src, src_idx, tar_idx, target_client=es_des, op_type='create', query={'query': {'match_all': {}}})
^
|
add this
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.