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":{}

}

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM