groovy - Elasticsearch 如何在更新中使用脚本(文件)

标签 groovy elasticsearch

我想更新一份给定的文件;使用保存的脚本

curl -XPOST 'http://localhost:9200/customer92/listbuilder/a10/_update' -d '
{
     "_script": {
      "script":"summarization"
       }
}'

我的 config/scripts 文件夹中有一个 summarization.groovy。我收到以下错误:

{
   "error":
       "ElasticsearchIllegalArgumentException[failed to execute script]; nested:     
        GroovyScriptExecutionException[MissingPropertyException[No such property: 
        summarization for class: Script6]]; ",
   "status":400
}

我做错了什么?

最佳答案

编辑:自从这个答案(来自文档)以来,Elasticsearch 发生了很大变化。请引用最新的文档,例如https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts

我很确定这个问题不再相关,但如果有人仍然感兴趣的话:

json 中的“脚本”字段应该是一个实际的脚本,而不是脚本的名称。在您的情况下,script_id 是正确的,除非更改了默认值,否则还应添加语言名称。

curl -XPOST 'http://localhost:9200/customer92/listbuilder/a10/_update' -d ' { "script_id":"总结", “朗”:“时髦” }'

有关详细信息,请参阅:Indexed ScriptsUpdate API

关于groovy - Elasticsearch 如何在更新中使用脚本(文件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25415375/

相关文章:

unit-testing - Grails/Spock : How to mock single method within class where method is called from within the class itself?

java - 如何从 :class [Ljava. lang.String 中删除元素?

python - Elasticsearch查询未返回正确的响应

elasticsearch - 如何使ElasticSearch仅产生字段的前几个单词?

ruby - 为什么 Ruby Builder 的 XmlMarkup 使用与 groovys 的 NodeBuilder 不同的语法

java - Intellij idea 2022.1.3 ultimate 显示错误java : JPS incremental annotation processing is disabled

java.lang.IllegalStateException : Failed to introspect Class 错误

elasticsearch - 不应将elastalert中的警报静音

php - 签署 ElasticSearch AWS 调用

json - 如何使用httpbuilder在groovy中将http get响应作为完整的json字符串检索