【ES索引】修改索引中serverid、dataserverid

升级或迁移中客户的server服务或备份服务器有替换,会有设备id改变的情况,导致之前id的视频数据无法播放。可以通过以下方法修改之前索引中记录的serverid或备份服务器id

使用curl命令请求ES接口

修改serverid:

(注意esip和索引日期,5.6ES和7.8ES索引名称数据结构不一样所以命令也不一样)

5.6ES:

curl -l -s -k -H “Content-type: application/json” -XPOST 192.168.2.83:9200/metadata-2022-3-*/session/_update_by_query -d ‘{“script”:{“source”:”ctx._source.serverid=\”要修改成的id\”;”,”lang”:”painless”},”query”:{“term”:{“serverid.keyword”:”被修改的旧id”}}}’

7.8ES:

curl -l -s -k -H “Content-type: application/json” -XPOST 192.168.2.83:9200/meta-session-2022-3-*/_update_by_query -d ‘{“script”:{“source”:”ctx._source.serverid=\”要修改成的id\”;”,”lang”:”painless”},”query”:{“term”:{“serverid”:”被修改的旧id”}}}’

修改dataserverid:

(注意esip和索引日期,5.6ES和7.8ES索引名称不一样)

5.6ES:

curl -l -s -k -H “Content-type: application/json” -XPOST 192.168.2.83:9200/metadata-2022-3-*/session/_update_by_query -d ‘{“script”:{“source”:”ctx._source.dataserverid=\”要修改成的id\”;”,”lang”:”painless”},”query”:{“term”:{“dataserverid.keyword”:”被修改的旧id”}}}’

7.8ES:

curl -l -s -k -H “Content-type: application/json” -XPOST 192.168.2.83:9200/meta-session-2022-3-*/_update_by_query -d ‘{“script”:{“source”:”ctx._source.dataserverid=\”要修改成的id\”;”,”lang”:”painless”},”query”:{“term”:{“dataserverid”:”被修改的旧id”}}}’