ES脚本更新数据

官网:https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-docvalue-fields.html

最近工程中用到要扫描所有的document下的nested的数据,大神给写了一个ES脚本,随笔记录下:

POST  /index/_update_by_query/conflicts=proceed

{

"script":{

"inline":"for(obj  in ctx._source.object_list) {

if(obj.id_value_pair!=null) continue;

if(obj.object_id.startwith('p')){obj.id_value_pair=obj.object_id+'-'+obj.object_value[0];}}",

"lang":"painless"},

"query":{

"match_all":{}

}

}

原文地址:https://www.cnblogs.com/brucexiang/p/9759103.html