Update doc using aggretaion result


(Ravi Randev Singh) #1

Hi Everyone,

I want to know is there a way to update doc with result of the aggregation, something like this

POST /index/type/_update_by_query
{
"query":{
"match_all": {}
},
"aggs" : {
"count_years" : {"cardinality" : {"field" : "costYear"}},
"max_costYear" : { "max" : { "field" : "costYear" } },
"min_costYear" : { "min" : { "field" : "costYear" } }
},
"script":{
"inline":"ctx._source.val1=aggs.count_years * value", //something like this what i want
"lang":"javascript" ,
"params":{
"value":"5"
}
}
}

Thanks for any help/ suggestion


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.