嗨我想知道如何从无痛脚本中提取数组长度?
{
"script": {
"lang": "painless",
"source": "what should be here???) {
"params": {
"plus": ["a","b","c"], //how to retrieve 3 as plus length?
}
}
答案 0 :(得分:0)
params
是一个HashMap,其中plus
是一个ArrayList。
您可以通过以下方式获取其长度:
"script": {
"lang": "painless",
"inline": "return params.plus.size()",
"params": {
"plus": ["a","b","c"]
}
}