原mappings如下
{
"audit_demo_bak": {
"mappings": {
"_doc": {
"properties": {
"full_name": {
"type": "text",
"analyzer": "ik_max_word"
}
}
}
}
}
}
想要新增full_name_copy字段,类型为keyword,并初始化值为full_name
步骤1 新增字段
PUT {{di}}/audit_demo/_doc/_mapping
{
"properties": {
"full_name_copy": {
"type": "keyword"
}
}
}
步骤2 使用painless赋值
POST {{di}}/audit_demo/_update_by_query
{
"script": {
"lang": "painless",
"inline": "ctx._source.full_name_copy = ctx._source.full_name"
}
}