1

Heroku で Bonsai Elastic Search を使用しており、次のようなドキュメントがあります。

{
   "_index":"myIndex",
   "_type":"result",
   "_id":"1234_is",
   "_version":1,
   "found":true,
   "_source":{
      "query":"is",
      "pubId":1234,
      "counter":1
   }
}

このようにカウンターを更新しようとしています ( http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/docs-update.htmlに従って):

curl -XPOST 'http://ELASTICSEARCHINSTANCE:9200/myIndex/result/1234_is/_update' -d '{"script" : "ctx._source.counter+=1"}'

しかし、次のエラーが発生します。

{
   "error":"ElasticsearchIllegalArgumentException[failed to execute script]; nested: ExpressionScriptCompilationException[Failed to parse expression: ctx._source.counter+=1]; nested: ParseException[ unexpected character '1' at position (21).]; nested: MismatchedTokenException; ",
   "status":400
}
4

2 に答える 2

1

ES 1.4.4 では、次のように動作させました。

  1. 次の行を elasticsearch.yml ファイルに追加します。script.groovy.sandbox.enabled: true
  2. ESを再起動

次に、次のセットアップを実行しましたが、うまくいきました。

PUT hilden1

PUT hilden1/type1/_mapping
{
  "properties": {
    "title": {
      "type": "string"
    },
    "counter": {
      "type": "integer"
    }
  }
}

POST hilden1/type1/1
{
  "title": "t1",
  "counter": 1
}

POST hilden1/type1/2
{
  "title": "t2",
  "counter": 2
}

GET hilden1/type1/_search
{

}

POST hilden1/type1/1/_update
{
  "script": "ctx._source.counter+=1",
  "lang": "groovy"
}
于 2015-03-03T16:30:14.423 に答える
1

ここで盆栽の創始者。

安全上の理由から、Bonsai は、マルチテナント環境でサンドボックス化された言語を使用した動的スクリプトのみをサポートしています。CVE-2015-1427 とElasticsearch 1.4.3 および 1.3.8のリリースに続いて、Groovy は Elasticsearch のサンドボックス化された動的スクリプトの安全な言語と見なされなくなりました。

とはいえ、Groovy は Bonsai のシングルテナント クラスタ上で完全に安全です。info@bonsai.io までご連絡ください。そのようなセットアップの見積もりを取得します。

于 2015-03-28T18:03:26.603 に答える