当其他守护进程(可能)也在更新文档时,我希望通过对弹性查询来执行更新。其后果是版本冲突。
我希望获得所有(不仅仅是一个大容量)冲突文档I的列表(用于手动重试),或者设置retry_on_conflict以便通过查询进行更新。
我该怎么做呢?
我的查询示例:
"script": {
"inline": "ctx._source['msp']=null",
"lang": "painless"
},
"query": {
"bool": {
"must_not": {
"terms": {
"msp-rev": [44]
}
},
"must" : {
"exists": {
"field": "msp"
}
}
}
}发布于 2022-07-08 14:21:21
Tldr;
将update_by_query与conflicts=proceed结合使用。这不会中止您的更新。在响应中,您将有一个数组failures,其中所有失败的id都是。
POST /<index>/_update_by_query?conflicts=proceed
{
"script": {
"inline": "ctx._source['msp']=null",
"lang": "painless"
},
"query": {
"bool": {
"must_not": {
"terms": {
"msp-rev": [44]
}
},
"must" : {
"exists": {
"field": "msp"
}
}
}
}
}手动使用更新查询逐个更新文档。
POST /<index>/_update/<_id>?retry_on_conflict=<some value>
{
"doc": {
"msp": null
}
}https://stackoverflow.com/questions/45688007
复制相似问题