首页 > 代码库 > ElasticSearh更新nested字段(Array数组)。怎么根据查询条件(query)复制一个(index)到新的Index how to update by query a nested fields data for elasticsearch
ElasticSearh更新nested字段(Array数组)。怎么根据查询条件(query)复制一个(index)到新的Index how to update by query a nested fields data for elasticsearch
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‘" //更新普通字段 }}
ElasticSearh更新nested字段(Array数组)。怎么根据查询条件(query)复制一个(index)到新的Index how to update by query a nested fields data for elasticsearch
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。