es查询字段更新记录_ElasticSearh更新nested字段(Array数组)。怎么根据查询条件(query)复制一个(index)到新的Index how to update by query...

GET usernested/_search

{

"query": {

"nested": {

"path": "tags",

"query": {

"bool": {

"must": [

{

"term": {

"tags.brandid": "93a8296c-5b64-49ea-bd92-b19192def2e9"

}

},

{

"term": {

"tags.site": "163"

}

}

]

}

}

}

}

}

//按照条件新建一个 index 作为测试数据使用

POST _reindex

{

"source": {

"index": "usernested",

"query": {

"nested": {

"path": "tags",

"query": {

"bool": {

"must": [

{

"term": {

"tags.brand": "c55fd643-1333-4647-b898-fb3e5e4e6d67"

}

},

{

"term": {

"tags.site": "163"

}

}

]

}

}

}

}

},

"dest": {

"index": "new_usernested"

}

}

//查询

GET new_usernested/_search

{

"query": {

"nested": {

"path": "tags",

"query": {

"bool": {

"must": [

{

"term": {

"tags.brand": "c55fd643-1333-4647-b898-fb3e5e4e6d67"

}

},

{

"term": {

"tags.site": "163"

}

}

]

}

}

}

}

}

//根据条件更新一个 nested 的文档

GET usernested/_update_by_query

{

"query": {

"nested": {

"path": "tags",

"query": {

"bool": {

"must": [

{

"term": {

"tags.brand": "c55fd643-1333-4647-b898-fb3e5e4e6d67"

}

},

{

"term": {

"tags.site": "163"

}

}

]

}

}

}

},

"script": {

"inline": "for(e in ctx._source.tags){e.brand = 'test2';}" //更新 nested 字段

//"inline":"ctx._source.userid = 'testid'" //更新普通字段

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值