es添加新字段并更新历史数据的默认值

PUT /es_student_brands/_mapping
{
“properties”: {
“is_auth”: {
“type”: “byte”
},
“auth_time”: {
“type”: “date”,
“format”: “yyyy-MM-dd HH:mm:ss”
}
}
}

// 更新历史值为2

POST es_student_brands/_update_by_query?conflicts=proceed&wait_for_completion=false
{
“script”: {
“lang”: “painless”,
“inline”: “if (ctx._source.is_auth== null) {ctx._source.is_auth= ‘2’}”
}
}

//更新历史值为null

POST /es_student_brands/_update_by_query?conflicts=proceed&wait_for_completion=false
{
“script”: {
“source”: “ctx._source[‘auth_time’] = null”,
“lang”: “painless”
},
“query”: {
“match_all”: {}
}
}