注意 py 代码要和 mapping 目录在同一级,mapping 目录下存放索引库的 json 文件,文件名为index_name.json
py代码
import requests
import json
import os
mapping_folder = "./mapping"
headers = {"Content-Type":"application/json","Accept":"application/json"}
is_append = True
## 新集群host
newClusterHost = ""
## 新集群用户名,可为空
newClusterUser = ""
## 新集群密码,可为空
newClusterPassword = ""
def syn_index(index_name, data):
# 索引存在则放弃同步
if exist_index(index_name):
return
print("syn_index-start:{}".format(index_name))
syn_index_res = requests.put("http://" + newClusterHost + ":9200/" + index_name,
auth=(newClusterUser, newClusterPassword),
headers={"content-type": "application/json"},