高峰只对攀登它而不是仰望它的人来说才有真正意义。

elasticsearch update_by_query怎么给字段自增长

Elasticsearch | 作者 chenkongzhang | 发布于2020年09月08日 | 阅读数:1680

一次update_by_query,找出所有满足条件的文档,文档中的priority根据文档返回顺序从1自增加赋值。
POST sku_index_latest/_update_by_query
{
"query": {
"bool": {
"filter": {
"nested": {
"path": "tagBos",
"query": {
"bool": {
"filter": [
{
"term": {
"tagBos.tagId.keyword": {
"value": "A001"
}
}
},
{
"term": {
"tagBos.isActive": {
"value": false
}
}
}
]
}
}
}
}
}
},
"script": {
"source": "for(tag in ctx._source.tagBos){if (tag.tagId == 'A001') {tag.isActive = true}}"
}
}
已邀请:

要回复问题请先登录注册