es 给现有的索引增加字段方法

给xxxxdriver_reason_new_yyyyMMdd 增加driver_name_enc 字段,并且配置默认值为空是不是这样写。 

# 熟悉给mapping 增加字段
PUT xxx_driver_reason_new_yyyyMMdd/_mapping
{
    "properties": {
        "driver_name_enc": {
            "type": "keyword"
        }
    }
}


# 方法一 批量给旧的索引增加字段
POST xxxxdriver_reason_new_yyyyMMdd/_update_by_query
{
  "script": {
    "source": "ctx._source['driver_name_enc'] = \"\""
  }
}

# 方法二 一行行的增加字段
POST xxxxdriver_reason_new_yyyyMMdd/_doc/1/_update
{
    "doc" : {
        "driver_name_enc" : ""
    }
}

你可能感兴趣的:(elasticsearch,elasticsearch)