nas
nas

Reputation: 2437

Write the query to update the document

I have following mapping and indexed document:

  "my_locations": {
    "aliases": {

    },
    "mappings": {
      "_doc": {
        "properties": {
          "location": {
            "type": "geo_point"
          },
          "name_e": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "province_e": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    },

With the following query I have inserted a data

PUT my_locations/_doc/1
{
  "location" : {
      "lat" : 40.92,
      "lon" : -71.34
  }
}

where I forgot to add name_e & province_e to above query. How can I write update query to insert name and province for doc 1?

Upvotes: 1

Views: 30

Answers (1)

Val
Val

Reputation: 217564

You can do it like this using the update API:

POST my_locations/_doc/1/_update
{
  "doc" : {
      "name_e": "some name",
      "province_e": "some province"
  }
}

Upvotes: 1

Related Questions