gpt4 book ai didi

elasticsearch - 如何在 Elasticsearch 中复制索引?

转载 作者:行者123 更新时间:2023-12-02 23:12:33 30 4
gpt4 key购买 nike

我正在进行 flex 搜索,我想在本地 flex 搜索实例上创建与在生产实例上创建的索引相同的索引,并使用相同类型的映射和设置,
我能想到的一种方法是设置相同的映射,还有其他更好的方法将索引元数据复制到本地,谢谢

最佳答案

只需将GET请求发送到https://source-es-ip:port/index_name/_mappings
并将输出放入https://destination-es-ip:port/index_name

复制数据可以通过Elasticsearch Reindex API实现,
作为引用,您可以看到此link
例如,要实现此目的,我将使用此python Script-

from elasticsearch import Elasticsearch
from elasticsearch.helpers import reindex
import urllib3

urllib3.disable_warnings()
es_source = Elasticsearch(hosts=['ip:port'],<other params>)
es_target = Elasticsearch(hosts=['ip:port'],<other params>)

for index in es.indices.get('<index name/pattern>')
r = reindex(es_source, source_index=index, target_index=index, target_client=es_target, chunk_size=500)
print(r)

即使在跨ES的不同版本复制索引时,这也适用于所有版本

关于elasticsearch - 如何在 Elasticsearch 中复制索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58797226/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com