更新ES 2.4.0文档中的特定字段?

时间:2017-02-22 17:13:55

标签: elasticsearch

我有这样的文件

               "College": "UCLA",
               "University": "American",
               "Branch": "MECH",
               "Name": {
                  "first": "john",
                  "middle": "william",
                  "last": "Richards"
                 }

我必须更新last群组中的Name字段

我尝试了以下但是显示错误

POST alma/matter/1/_update
{
  "doc": { "Name.last": "junior" }
}

错误:

{
   "error": {
      "root_cause": [
         {
            "type": "mapper_parsing_exception",
            "reason": "Field name [Name.last] cannot contain '.'"
         }
      ],
      "type": "mapper_parsing_exception",
      "reason": "Field name [Name.last] cannot contain '.'"
   },
   "status": 400
}

1 个答案:

答案 0 :(得分:0)

您不允许引用带点的字段。你可以这样做:

POST alma/matter/1/_update
{
  "doc": { "Name": {"last": "junior" }}
}