举例子:索引A为旧索引,索引B为新索引。
1、获取A索引(旧索引)的数据结构
GET /index_a/_mapping/
2、创建一个新的索引B,结构同A。
POST /index_b/_mapping/
{
"properties" : {
"age" : {
"type" : "long"
},
"education" : {
"type" : "text"
},
"other": {
"type": "text"
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"testedu" : {
"type" : "text"
}
}
}
3、elasticsearch.yml 设置白名单
# 开启跨域
http.cors.enabled: true
# 所有人访问
http.cors.allow-origin: "*"
# network.host: 192.168.1.127
# http.port: 9200
# transport.tcp.port: 9300
reindex.remote.whitelist: "192.168.0.202:9200, 192.168.0.202:9200,127.0.10.*:9200, localhost:*"
4、迁移数据
POST _reindex
{
"source": {
"remote": {
"host": "http://192.168.0.202:9200"
},
"index": "index_a"
},
"dest": {
"index": "index_b"
}
}