"update":{"id":"hr324hdie93hdjdo391","type":"user","index":"jal","routing":2,"retry_on_conflict":5}}
{"lang":"mvel","script":"if(ctx.source.containsKey(\"category\")){i=0; io=0; foreach (item : ctx.source.category){i++; if (item[ 'key' ] == v_123_purchased){ io=1}} if(io==0){ctx.source.category.add(p123_purchased);}}else{ctx.source.category=c123_purchased;}if(ctx.source.containsKey(\"category\")){i=0; io=0; foreach (item : ctx.source.category){i++; if (item[ 'key' ] == v_233_purchased){ io=1}} if(io==0){ctx.source.category.add(p233_purchased);}}else{ctx.source.category=c233_purchased;}foreach (item : ctx.source.category) { if (item[ 'key' ] == key123_purchased) { if(item[ 'name' ]==null){item[ 'name' ] =name_123_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key123_purchased) { if(item[ 'action' ]==null){item[ 'action' ] =action_123_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key123_purchased) {if(item[ 'price' ]==null){item[ 'price' ]=price_123_purchased;}else{ item[ 'price' ]=item[ 'price' ]+ price_123_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key123_purchased) {if(item[ 'count' ]==null){item[ 'count' ]=count_123_purchased;}else{ item[ 'count' ]=item[ 'count' ]+ count_123_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key123_purchased) {if(item[ 'last_date' ]==null){item[ 'last_date' ]=last_date_123_purchased;}else{ item[ 'last_date' ] = last_date_123_purchased; } }}foreach (item : ctx.source.category) { if (item[ 'key' ] == key123_purchased) {if(item[ 'with_promo' ]==null){item[ 'with_promo' ]=with_promo_123_purchased;}else{ item[ 'with_promo' ]=item[ 'with_promo' ]+ with_promo_123_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key233_purchased) { if(item[ 'name' ]==null){item[ 'name' ] =name_233_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key233_purchased) { if(item[ 'action' ]==null){item[ 'action' ] =action_233_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key233_purchased) {if(item[ 'price' ]==null){item[ 'price' ]=price_233_purchased;}else{ item[ 'price' ]=item[ 'price' ]+ price_233_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key233_purchased) {if(item[ 'count' ]==null){item[ 'count' ]=count_233_purchased;}else{ item[ 'count' ]=item[ 'count' ]+ count_233_purchased;} } }foreach (item : ctx.source.category) { if (item[ 'key' ] == key233_purchased) {if(item[ 'last_date' ]==null){item[ 'last_date' ]=last_date_233_purchased;}else{ item[ 'last_date' ] = last_date_233_purchased; } }}foreach (item : ctx.source.category) { if (item[ 'key' ] == key233_purchased) {if(item[ 'with_promo' ]==null){item[ 'with_promo' ]=with_promo_233_purchased;}else{ item[ 'with_promo' ]=item[ 'with_promo' ]+ with_promo_233_purchased;} } }","params":{"p_123_purchased":{"key":"123_purchased"},"c_123_purchased":[{"key":"123_purchased"}],"v_123_purchased":"123_purchased","p_233_purchased":{"key":"233_purchased"},"c_233_purchased":[{"key":"233_purchased"}],"v_233_purchased":"233_purchased","key_123_purchased":"123_purchased","name_123_purchased":123,"action_123_purchased":"purchased","price_123_purchased":20,"count_123_purchased":1,"last_date_123_purchased":"2015-07-04T07:11:03","with_promo_123_purchased":1,"key_233_purchased":"233_purchased","name_233_purchased":233,"action_233_purchased":"purchased","price_233_purchased":20,"count_233_purchased":1,"last_date_233_purchased":"2015-07-04T07:11:03","with_promo_233_purchased":1}}
Trying To update this type of object
{
"_userId": "hr324hdie93hdjdo391",
"_shardId": 2,
"brand": [
{
"price": 140,
"name": 23,
"count": 7,
"without_promo": 7,
"action": "purchased",
"key": "23_purchased",
"last_date": "2015-07-04T10:10:25"
}
],
"product": [
{
"price": 140,
"with_promo": 7,
"name": 28,
"count": 7,
"action": "purchased",
"key": "28_purchased",
"last_date": "2015-07-04T10:10:25"
},
{
"price": 40,
"with_promo": 2,
"name": 29,
"count": 2,
"action": "purchased",
"key": "29_purchased",
"last_date": "2015-07-04T06:25:30"
}
],
"category": [
{
"price": 140,
"with_promo": 7,
"name": 123,
"count": 7,
"action": "purchased",
"key": "123_purchased",
"last_date": "2015-07-04T10:10:25"
},
{
"price": 40,
"with_promo": 2,
"name": 124,
"count": 2,
"action": "purchased",
"key": "124_purchased",
"last_date": "2015-07-04T06:25:30"
} ]
}