Elasticsearch更新带有部分文档覆盖原始文档



使用部分文档覆盖原始文档而不是合并它。

我认为合并只会更新相应的属性和/或插入新属性。我错过了合并该怎么办?

这就是我的方式:

映射:

PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "user": {
          "type": "nested" 
        }
      }
    }
  }
}

索引文档:

PUT my_index/my_type/1
{
  "group" : "fans",
    "user" : [
      {
        "first" : "John",
        "last" :  "Doe",
        "age": 31
      },
      {
        "first" : "Foo",
        "last" :  "Bar",
        "age" : 26
       }
     ]
}

部分更新:

POST my_index/my_type/1/_update
{
  "doc": {
      "group" : "fans",
        "user" : [
        {
          "first" : "Joe",
          "last" :  "Smith",
        },
        {
          "first" : "Alice",
          "last" :  "Baz"
        }
      ]
  }
}

结果只是没有age属性的新文档。我如何保存不在部分更新中的属性?

提供的帖子不使用与原始put相同的索引和类型名称。尝试POST my_index/my_type/1/_update代替POST test/type1/1/_update

最新更新