0

嗨,我想知道如何从无痛脚本中提取数组长度?

{
   "script": {
   "lang": "painless",
     "source": "what should be here???) { 
"params": {
  "plus": ["a","b","c"],   //how to retrieve 3 as plus length?
}
 }
4

1 回答 1

0

params是一个HashMap,其中plus是一个ArrayList。您可以通过以下方式获取其长度:

"script": {
  "lang": "painless",
  "inline": "return params.plus.size()",
  "params": {
    "plus": ["a","b","c"]
  }
}
于 2018-07-10T11:54:37.533 回答