从 Elastic 脚本 Params 循环遍历数组

Loop through array from Elastic script Params

我正在创建一个 (ElasticSearch) 无痛脚本。作为参数,我正在设置一个数组,但我无法在我的脚本中循环遍历该数组。

弹性参数setter(使用 NEST):

Params = new Dictionary<string, object>
             {
               { "ages", new []{2,4,6}},
             }

无痛脚本:

for(int age in params.ages)
{
 // do something
}

错误:

"script_stack": [
                    "... for(int age in params.ages){ ...",
                    "                ^---- HERE"
                ],

如何将参数用作数组?

看来您需要更改

中的循环定义
for(int age in params.ages)

for(age in params.ages)

希望对您有所帮助。