1、需要把之前数据复制到新索引,涉及到索引有
es查看: curl -s localhost:9210/_cat/indices |grep sw |grep -v "2019"
network_address_inventory
service_inventory
service_instance_inventory
endpoint_inventory
register_lock
2、复制索引数据,自行变更索引名称
curl -XPOST 'http://127.0.0.1:9210/_reindex?pretty' -d '{
"conflicts": "proceed",
"source": {
"index": "sw1_service_inventory"
},
"dest": {
"index": "sw_service_inventory",
"version_type": "external"
}
}' -H 'Content-Type:application/json'
3、service_instance_inventory索引多了字段,需要初始化last_update_time、register_time、heartbeat_time
curl -XPOST 'localhost:9210/sw_service_instance_inventory/_update_by_query?pretty' -H 'Content-Type: application/json' -d'{
"script":{
"source":"ctx._source.last_update_time=1576736982;ctx._source.register_time=1576736982;ctx._source.heartbeat_time=1576736982"
},
"query":{"match_all":{}
}
}'
4、service_inventory索引字段名称变更了,由mapping_last_update_time变为last_update_time,同理需要初始化last_update_time、register_time、heartbeat_time
curl -XPOST 'localhost:9210/sw_service_inventory/_update_by_query?pretty' -H 'Content-Type: application/json' -d'{
"script":{
"source":"ctx._source.last_update_time=1576736982;ctx._source.register_time=1576736982;ctx._source.heartbeat_time=1576736982"
},
"query":{"match_all":{}
}
}'
5、network_address_inventory多了last_update_time、register_time、heartbeat_time
curl -XPOST 'localhost:9210/sw_network_address_inventory/_update_by_query?pretty' -H 'Content-Type: application/json' -d'{
"script":{
"source":"ctx._source.last_update_time=1576736982;ctx._source.register_time=1576736982;ctx._source.heartbeat_time=1576736982"
},
"query":{"match_all":{}
}
}'
6、endpoint_inventory多了last_update_time、register_time、heartbeat_time
curl -XPOST 'localhost:9210/sw_endpoint_inventory/_update_by_query?pretty' -H 'Content-Type: application/json' -d'{
"script":{
"source":"ctx._source.last_update_time=1576736982;ctx._source.register_time=1576736982;ctx._source.heartbeat_time=1576736982"
},
"query":{"match_all":{}
}
}'