更新Elasticsearch文档

问题描述:

此代码可以正常工作.但是,我不想将第三个国家/地区添加为另一个文档,而是要更新第一个文档.

This code is working as expected. But instead of adding the third country as another document, I want to update the first document.

DELETE /test_index

PUT /test_index

PUT /test_index/doc/1
{
   "parent": [
      {
         "name": "India",
         "label": "IN"
      },
      {
         "name": "China",
         "label": "CN"
      }
   ]
}

PUT /test_index/doc/2
{
   "parent": [
      {
         "name": "Pakistan",
         "label": "PK"
      }
   ]
}

因此,文档ID 1将有3个国家:印度,中国和巴基斯坦.我想我需要使用doc_as_upsert参数更新API.但是我不确定如何编写JSON.

So that the Document ID 1 will have 3 countries India, China and Pakistan. I guess I need update API with doc_as_upsert parameter. But I am not sure how to write the JSON.