使用script更新數(shù)組數(shù)據(jù)時(shí) script如下
StringSCRIPT_TEMPLATE_FOR_ADD_ARRAY_INFO ="if(ctx._source.containsKey('%s')){if(!ctx._source.%s.contains(params.%s)){ctx._source.%s.add(params.%s)}} else {ctx._source.%s =[params.%s]}";
StringSCRIPT_TEMPLATE_FOR_REMOVE_ARRAY_INFO ="if(ctx._source.%s.contains(params.%s)){ ctx._source.%s.remove(ctx._source.%s.indexOf(params.%s))}";
其中 use_limit_category的mapping為long類型逮京,但是params中value為long或Long時(shí) 腳本執(zhí)行不正確睛驳,數(shù)組中存在一個(gè)值時(shí)仍然執(zhí)行add操作糠聪,remove同理? ?改為Integer時(shí)正常,猜測(cè) mapping中type 為long 但 es存儲(chǔ)為java.long.Integer