我试图从curl命令行执行.groovy文件但是失败&收到以下错误如下。这是我的设置:
elasticsearch.yml
script.inline: true
script.indexed: true
config / scripts / ** counterPostCount.groovy **
postCount += 1
注意:基本上我想加1我已经拥有的价值' postCount'我的文件中的字段。
document:hashtag
{ "把" :3, " TIMED_OUT" :假的, " _shards" :{ "总" :5, "成功" :5, "失败" :0 }, "命中" :{ "总" :1, " MAX_SCORE" :1.0, "命中" :[{ " _index" :"#标签", " _type" :"#标签", " _id" :" b3ecb430-9fa6-4f41-84da-b79e6a30ef00", " _score" :1.0, " _source" :{ " ID" :" b3ecb430-9fa6-4f41-84da-b79e6a30ef00", " hashtagId" : 空值, " hashtagname" :" helloworld", " dateCreated会" : 空值, " dateUpdated" : 空值, " postCount" :2 } }] } }
卷曲命令
curl -XPOST 'http://localhost:9200/hashtag/hashtag/b3ecb430-9fa6-4f41-84da-b79e6a30ef00/_update' -d '{"_script" : {"script_id" : "counterPostCount", "lang" : "groovy"}}'
错误
{"错误" {" ROOT_CAUSE":[{"类型":" remote_transport_exception""理由&#34 ;:" [节点1] [127.0.0.1:9300] [指数:数据/写/更新[S]]"}],"类型":" illegal_argument_exception&# 34;,"原因":"未能执行脚本"," caused_by":{" type":" index_not_found_exception&#34 ;,"原因":"没有这样的索引"," resource.type":" index_expression"," resource.id&# 34;:" .scripts中""指数":" .scripts中"}},"状态" 400}
答案 0 :(得分:1)
你几乎就在那里,但你的查询中有两个拼写错误,
_script
应该是`script`` script_id
用于索引脚本(提示:错误提示没有.script
索引),而是使用file
代替文件脚本它应该是这样的:
curl -XPOST 'http://localhost:9200/hashtag/hashtag/b3ecb430-9fa6-4f41-84da-b79e6a30ef00/_update' -d '{
"script" : {
"file" : "test",
"lang" : "groovy"
}
}'
您不必更改elasticsearch.yml
文件中的任何内容,因为文件脚本为enabled by default