使用预先安装在elasticsearch中的脚本进行更新

时间:2015-06-25 06:32:25

标签: elastic4s

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

我在<?xml version='1.0' encoding='utf-8'?> <widget id="Mordor" version="1.0.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" rim:backButton="exit"> <name>Mordor</name> <author email="application author's e-mail">application's author</author> <description> Mordor </description> <license href="http://opensource.org/licenses/alphabetical"> </license> <access subdomains="true" origin="file:///store/home" /> <access subdomains="true" origin="file:///SDCard" /> <!-- start_worklight_host_server do not change this line--> <access subdomains="true" origin="https://example.com" /> <!-- end_worklight_host_server do not change this line--> <access subdomains="true" origin="*" /> <icon src="icon.png" /> <rim:splash src="splash-1024x600.png" /> <rim:splash src="splash-600x1024.png" /> <rim:splash src="splash-1280x768.png" /> <rim:splash src="splash-768x1280.png" /> <content src="webresources/skinLoader.html" /> <rim:permissions> <rim:permit>read_device_identifying_information</rim:permit> <rim:permit>access_shared</rim:permit> <rim:permit>read_geolocation</rim:permit> <rim:permit>access_pimdomain_contacts</rim:permit> </rim:permissions> </widget> (Chrome插件)中试过这个,效果很好。想知道如何在elastic4s中实现这一目标。

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

sense

但失败了。

1 个答案:

答案 0 :(得分:0)

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

def replaceWithId(alarmId: String) = {
  client.execute {
    update id alarmId in IndexType script("scriptname", ScriptType.File)
  }
}