0

Hi i wonder how i can extract an array length from painless script?

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

1 Answers1

0

params is a HashMap, in which plus is an ArrayList. You can get its length by:

"script": {
  "lang": "painless",
  "inline": "return params.plus.size()",
  "params": {
    "plus": ["a","b","c"]
  }
}
Rahul Singhai
  • 1,299
  • 15
  • 27