ES索引迁移 可跨服务器

使用ElasticSearch的HTTP接口
使用Python对HTTP进行封装
迁移时将所需迁移的Field进行替换即可

import json
import requests

url = "http://127.0.0.1:9200/索引名/_search?size=索引个数&from=0"
# 此处填写你的ElasticSearch的URL
data = {
    "query": {
        "match_all": {
        }
    }
}
# 使用match_all对原始索引数据进行下载
HEADERS = {'Content-Type': 'application/json;charset=UTF-8'}
res = requests.get(url=url, data=json.dumps(data), headers=HEADERS)
res_js = res.json()
# print(res_js)
print(len(res_js['hits']['hits']))
n = 0
for i in range(0, len(res_js['hits']['hits'])):
    query = {
         # 可根据自己实际需要添加索引的FIE老师
        'Field1': res_js['hits']['hits'][i]['_source']['Field1'],
        'Field2': res_js['hits']['hits'][i]['_source']['Field2'],
        'Field3': res_js['hits']['hits'][i]['_source']['Field3'],
        'Field4': res_js['hits']['hits'][i]['_source']['Field4'],
        'Field5': res_js['hits']['hits'][i]['_source']['Field5'],
        'Field6': res_js['hits']['hits'][i]['_source']['Field6'],
        'Field7': res_js['hits']['hits'][i]['_source']['Field7']
    }
    url = 'http://新的URL:9200/新的索引的名/新的Type/' + str(res_js['hits']['hits'][i]['_source']['id'])
    es = requests.post(url=url, data=json.dumps(query), headers=HEADERS)