[英]update document with _id elasticsearch
I tried to update a document with _id
. 我尝试使用_id
更新文档。
POST http://example.org/testrest/_update/X3flr2oB9Don9XlKX05E
This is a part of doc.: 这是文档的一部分:
"hits": [
{
"_index": "testrest",
"_type": "testrest",
"_id": "X3flr2oB9Don9XlKX05E",
"_score": 0,
"_source": {
"price_diff_per_sys": "199.8999",
"specs": "",
"gtin_match": "0",
"human_verdict": "Awaiting",
And here's the request body: 这是请求正文:
{
"doc": {
"human_verdict": "Match"
}
}
But then I get this error: 但是然后我得到这个错误:
{
"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
} }
How can I update document with _id
? 如何使用_id
更新文档?
The URL is not malformed and the request body needs to be valid JSON, like this: 该网址没有格式错误,并且请求正文必须为有效的JSON,如下所示:
POST http://example.org/testrest/testrest/X3flr2oB9Don9XlKX05E/_update
{
"doc": {
"human_verdict": "Match"
}
}
The error message clearly saying that you passed the wrong _type
name which is _update
in your case, as it says in the error message, in short it can't start with _
. 错误消息清楚地表明您传递了错误的_type
名称(在您的情况下为_update
,正如错误消息中所指出的那样,简而言之,它不能以_
开头。 change it to something else and it should work. 将其更改为其他内容,它应该可以工作。
reason": "Document mapping type name can't start with '_', found: [_update]" 原因”:“文档映射类型名称不能以'_'开头,已找到:[_update]“
POST http://example.org/testrest/testrest/X3flr2oB9Don9XlKX05E/_update should work , as I noticed in your payload both indexname and type are same. POST http://example.org/testrest/testrest/X3flr2oB9Don9XlKX05E/_update应该可以正常工作,正如我在您的有效负载中注意到的,索引名和类型都相同。
"_index": "testrest",
"_type": "testrest",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.