1. 程式人生 > >elasticsearch中給已存在的mapping增加新欄位並賦值

elasticsearch中給已存在的mapping增加新欄位並賦值

es中建立後的mapping不可修改,但是可以新增新欄位
新增新欄位:

PUT /my_index/_mapping/my_type
{
  "properties": {
       "new_field_name": {
           "type":     "string"
       }
   }
}

賦值:

POST my_index/_update_by_query
{
  "script": {
    "lang": "painless",
    "inline": "ctx._source.new_field_name= '02'"
  }
}