我正在尝试使用接受三个参数的 UpdateRequest
通过 java api 更新索引中的值。
- 索引
- 文档
- ID
问题 - 我知道我的索引名称是什么,但我不确定应该在 document 和 id 字段中传递什么值。
样本数据
{
"took": 2,
"timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 },
"hits": {
"total": 1,
"max_score": 0.94064164,
"hits": [
{
"_index": "ticketdump",
"_type": "event",
"_id": "AVefK2vFmf0chKzzBkzy",
"_score": 0.94064164,
"_source": {
"clientversion": "123465",
"queue": "test,test",
"vertical": "test",
"troubleshooting": "test",
"reason": "test",
"status": "test",
"ticketversion": "1132465",
"apuid": 1,
"golive": "2014-07-14",
"clientname": "test",
"message": "test",
"product": "test",
"clientid": 1,
"createddatetime": "2016-05-03 09:43:48",
"area": "test",
"developmentfix": "test",
"actiontaken": "test",
"categoryname": "test",
"parentcategory": "test",
"problemdef": "test",
"ticketid": 1
}
}
]
}
}
我尝试传递 _source
对象,但它给出了文档缺失错误。也许我错过了这个概念?
JAVA代码
UpdateRequest updateRequest = new UpdateRequest(
"ticketdump",
js.getJSONObject("hits")
.getJSONArray("hits")
.getJSONObject(0)
.getJSONObject("_source")
.toString(),
"1"
).script(new Script("ctx._source.message = \"bhavik\""));
client.update(updateRequest).get();
最佳答案
实际上,您的 UpdateRequest 接受 3 个参数
- 索引
- 类型
- 身份证
通过以下数据可以看出:
- 索引 = 票务转储
- 类型 = 事件
- Id = AVefK2vFmf0chKzzBkzy
关于java - 通过java api更新elasticsearch中的索引时文档丢失异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39965225/