使用_id elasticsearch更新文档

时间:2019-05-14 04:59:20

标签: elasticsearch

我尝试使用_id更新文档。

POST http://example.org/testrest/_update/X3flr2oB9Don9XlKX05E

这是文档的一部分。

"hits": [
        {
            "_index": "testrest",
            "_type": "testrest",
            "_id": "X3flr2oB9Don9XlKX05E",
            "_score": 0,
            "_source": {
                "price_diff_per_sys": "199.8999",
                "specs": "",
                "gtin_match": "0",
                "human_verdict": "Awaiting",

这是请求正文:

{
  "doc": { 
    "human_verdict": "Match"
  }
}

但随后出现此错误:

{
"error": {
    "root_cause": [
        {
            "type": "invalid_type_name_exception",
            "reason": "Document mapping type name can't start with '_', found: [_update]"
        }
    ],
    "type": "invalid_type_name_exception",
    "reason": "Document mapping type name can't start with '_', found: [_update]"
},
"status": 400

}

如何使用_id更新文档?

2 个答案:

答案 0 :(得分:2)

该错误消息清楚地表明您传递了错误的_type名称,正如错误消息中所指出的那样,该名称就是_update,总之不能以{{1}开头}。将其更改为其他内容,它应该可以工作。

  

原因”:“找到的文档映射类型名称不能以'_'开头:   [_update]”

POST http://example.org/testrest/testrest/X3flr2oB9Don9XlKX05E/_update应该可以正常工作,正如我在您的有效负载中所注意到的,索引名和类型都相同。

_

答案 1 :(得分:1)

URL格式正确,请求正文必须是有效的JSON,如下所示:

update attachment_error a set
  a.file_id = (select c.file_id
               from attachment_claim c
               where c.claim_tcn_id = a.claim_tcn_id;
相关问题