1 删除原索引中要修改字段的数据
POST http://ip:port/原索引名称/
_update_by_query
{
"script": {
"lang": "painless",
"inline": "ctx._source.remove(\"update_time\")"
},
"query": {
"match_all": {}
}
}
2 新建一个索引,新的索引结构
PUT http:///ip:port/原索引名称_bak/
{
"settings": {
"index": {
"number_of_shards": 5,
"number_of_replicas": 1
}
},
"mappings": {
"properties": {
"update_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"busi_name": {
"type": "keyword"
}
}
}
}
3 将数据同步到新建的索引
POST http:///ip:port/
_reindex
{
"source": {
"index": "原索引名称"
},
"dest": {
"index": "原索引名称_bak"
}
}
4 删除原索引
DELETE http:///ip:port/原索引名称/
5 新建原索引
PUT http:///ip:port/原索引名称/
{
"settings": {
"index": {
"number_of_shards": 5,
"number_of_replicas": 1
}
},
"mappings": {
"properties": {
"update_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"busi_name": {
"type": "keyword"
}
}
}
}
6 将数据同步回原索引
POST http:///ip:port/
_reindex
{
"source": {
"index": "原索引名称_bak"
},
"dest": {
"index": "原索引名称"
}
}
7 删除新建的索引
DELETE http:///ip:port/原索引名称_bak/