正确写法
有两种,推荐这种
POST index/_update/id
{
"doc":{
"KEY":"VALUE"
}
}
_update
不要漏掉_
,"doc":{}
一定要写不然会报错
下面这种也能部分更新,但是写法已经过时了,会报警告#! Deprecation: [types removal] Specifying types in document update requests is deprecated, use the endpoint /{index}/_update/{id} instead.
POST index/_doc/id/_update
{
"doc":{
"KEY":"VALUE"
}
}
其他错误写法:
POST /index
这是更新索引设置,不是更新文档
POST /index/_doc/id
这是覆盖更新,不是部分更新,不传的字段会被删掉