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