es字段一旦创建是无法删除的,本案的方案是复制新老索引的方法
现有索引 index1,待删除字段field1和extendMap.field2,es版本6.3.2
1、删除index1中的filed1和extendMap.field2两个字段的数据
POST index1/_update_by_query
{
"query":{
"bool":{
"must":[
{
"exists":{
"field":"field1"
}
}
]
}
},
"script": "ctx._source.remove('field1')"
}
POST index1/_update_by_query
{
"query":{
"bool":{
"must":[
{
"exists":{
"field":"extendMap.field2"
}
}
]
}
},
"script": "ctx._source.extendMap.remove('field2')"
}
2、新建index2,map中不要有上述待删除字段
3、拷贝index1到index2
POST _reindex
{
"source": {
"index": "index1"
},
"dest": {
"index": "index2"
}
}
4、删除index1
DELETE index1
5、新建index1,map中不要有上述待删除字段
6、拷贝index2到index1
POST _reindex
{
"source": {
"index": "index2"
},
"dest": {
"index": "index1"
}
}
7、删除index2
DELETE index2
?完成