I've tried to execute .groovy file from curl command line but failed & received the following error as below. Here is my setup :
elasticsearch.yml
script.inline: true
script.indexed: true
config/scripts/** counterPostCount.groovy**
postCount += 1
Note : basically I want to plus 1 for the value that I already have for 'postCount' field in my document.
document : hashtag
{ "took" : 3, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 1.0, "hits" : [ { "_index" : "hashtag", "_type" : "hashtag", "_id" : "b3ecb430-9fa6-4f41-84da-b79e6a30ef00", "_score" : 1.0, "_source" : { "id" : "b3ecb430-9fa6-4f41-84da-b79e6a30ef00", "hashtagId" : null, "hashtagname" : "helloworld", "dateCreated" : null, "dateUpdated" : null, "postCount" : 2 } } ] } }
curl command
curl -XPOST 'http://localhost:9200/hashtag/hashtag/b3ecb430-9fa6-4f41-84da-b79e6a30ef00/_update' -d '{"_script" : {"script_id" : "counterPostCount", "lang" : "groovy"}}'
error
{"error":{"root_cause":[{"type":"remote_transport_exception","reason":"[Node1][127.0.0.1:9300][indices:data/write/update[s]]"}],"type":"illegal_argument_exception","reason":"failed to execute script","caused_by":{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_expression","resource.id":".scripts","index":".scripts"}},"status":400}