0

出于安全目的,我想以 [ https://www.elastic.co/blog/running-groovy-scripts-without-dynamic-scripting ] 的方式使用脚本。

我在(chrome插件)中试过这个,sense效果很好。想知道如何在 elastic4s 中实现这一点。

例如,我想从 doc 中删除一个字段,代码如下:

def replaceWithId(alarmId: String, fieldName: String, fieldValue: Map[String, Any]) = {
client.execute {
  update id alarmId in IndexType script """{"file":"removeOperationField"}"""

}}

但它失败了。

4

1 回答 1

0

您需要设置脚本类型,而不是将其明确包含在 json 中,例如:

def replaceWithId(alarmId: String) = {
  client.execute {
    update id alarmId in IndexType script("scriptname", ScriptType.File)
  }
}
于 2015-06-25T10:19:50.403 回答