我正在使用以下内容索引新文档
{
"lastUpdate" : "20180114144020452",
"name" : "My Process",
"startDate" : "20180114162356585",
"endData" : "",
"tasks" : [
{
"1" : {
"lastUpdate" : "20180114144020452",
"taskId" : "123",
"subject" : "Terceira Atividade",
"status" : "Active",
"type" : "userTask",
"assign" : [
{
"date" : "20180114144020452",
"type" : "role",
"name" : "Time 3",
"id" : "Team3_345"
}
],
"receivedDate" : "",
"readDate" : "",
"finishDate" : ""
}
}
]
}
然后我尝试使用以下更新内容更改task.1.status值
{
"doc" : {
"tasks" : [
{
"1" : {
"status" : "Closed"
}
}
]
}
}
但是它覆盖了整个任务.1结构,删除其他值并仅将状态值设置为关闭而不是保留其他值并仅更改状态值。
我该如何解决这个问题?感谢
答案 0 :(得分:2)
你需要通过像这样的
更新的脚本部分来完成POST updates/update/1/_update
{
"script": {
"source": "ctx._source.tasks[0].1.status = 'Closed'"
}
}