2016-06-17 6 views
2

から.groovyファイルの実行に失敗する私は、curlコマンドラインからの.groovyファイルを実行しようとしたが&は、以下のように次のエラーを受信失敗しました。ここに私のセットアップは次のとおりです。Elasticsearchスクリプト:curlコマンドライン

elasticsearch.yml

script.inline: true 
script.indexed: true 

設定/スクリプト/ ** counterPostCount.groovy **

postCount += 1 

注:基本的に私はしたいプラス値の1私はすでに私の文書の 'postCount'フィールドのために持っている。

文書:ハッシュタグ

{ は "取った":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"、 "理由": "[ノード1] [127.0.0.1:9300] "reason": "スクリプトの実行に失敗しました"、 "causes_by":{"type": "index_not_found_exception"、 "reason"、 "reason:data/write/update [s] ":"このようなインデックスはありません "、" resource.type ":" index_expression "、" resource.id ":"。scripts "、" index ":"スクリプト "}}、" ステータス ":400}

答えて

1

あなたはほとんどそこにいる、しかし、あなたはあなたのクエリで2つのタイプミスがあり、

  • _scriptは`
  • script_idをscript``れるべきですインデックス付きスクリプトのために:それは、この代わりのように読むべき

、ファイルのスクリプトの代わりにfileを使用します(ヒントエラーには.scriptインデックスが存在しないことに言及):

curl -XPOST 'http://localhost:9200/hashtag/hashtag/b3ecb430-9fa6-4f41-84da-b79e6a30ef00/_update' -d '{ 
    "script" : { 
    "file" : "test", 
    "lang" : "groovy" 
    } 
}' 

あなたは、ファイルのスクリプトが

+0

enabled by defaultはヴァルありがとうございますようごelasticsearch.ymlファイルに何かを変更する必要はありません。 _scriptとscript_idを置き換えましたが、次のように新しいエラーが発生しました: '{" error " 「reason」:「スクリプトの実行に失敗しました」、「causes_by」:{「type」:「script_exception」、「script_exception」、「script_exception」、 "reason": "lang [groovy]"、 "causes_by":{"type": "missing_property_exception"、 "reason": "このプロパティはありません:クラスのpostCount:a09142c1ac03bff417e4b55d8b280c22540b28b5"}}}を使用してファイルスクリプト[counterPostCount] 、 "status":400} ' – shkhssn

+0

2つの変更がありました。 – Val

+0

あなたの 'counterPostCount.groovy'スクリプトは存在しないように見える' postCount'フィールドを使います。 – Val

関連する問題