如何从无痛脚本中提取参数长度

时间:2018-05-27 15:22:56

标签: elasticsearch-painless

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

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

1 个答案:

答案 0 :(得分:0)

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

"script": {
  "lang": "painless",
  "inline": "return params.plus.size()",
  "params": {
    "plus": ["a","b","c"]
  }
}