简体   繁体   中英

Update a particular field in ES 2.4.0 document?

I have document like this

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

I have to update the last field in Name group

I tried with the following but it is showing error

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

Error:

{
   "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
}

You're not allowed to reference fields with dots in them. You can do it like this instead:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM