0
出於安全目的,我想以[https://www.elastic.co/blog/running-groovy-scripts-without-dynamic-scripting]的方式使用腳本。用elasticsearch預安裝的腳本更新
我在sense
(chrome插件)中試過,效果很好。想知道如何在elastic4s中實現這一點。
例如,我想刪除從文檔的字段,這樣的代碼:
def replaceWithId(alarmId: String, fieldName: String, fieldValue: Map[String, Any]) = {
client.execute {
update id alarmId in IndexType script """{"file":"removeOperationField"}"""
}}
,但失敗了。
是您的文件實際上是所謂的「removeOperationField」或「removeOperationField.groovy」什麼? – monkjack
文件名是removeOperationField,因爲它的類型是groovy,所以我們不必聲明lang。 –
java客戶端可以通過'client.prepareUpdate(「index」,「type」,「id」)做到這一點 .setScript(「removeIpField」,ScriptService.ScriptType.FILE) .get' –