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

use*_*283 6 groovy elasticsearch

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

curl -XPOST 'http://localhost:9200/customer92/listbuilder/a10/_update' -d '
{
     "_script": {
      "script":"summarization"
       }
}'
Run Code Online (Sandbox Code Playgroud)

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

{
   "error":
       "ElasticsearchIllegalArgumentException[failed to execute script]; nested:     
        GroovyScriptExecutionException[MissingPropertyException[No such property: 
        summarization for class: Script6]]; ",
   "status":400
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么 ?

mgo*_*zke -1

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

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

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

curl -XPOST 'http://localhost:9200/customer92/listbuilder/a10/_update' -d ' { "script_id":"summarization", "lang": "groovy" }'

有关更多详细信息,请参阅:索引脚本更新 API