【问题标题】:elasticsearch python script plugin in Update API更新 API 中的 elasticsearch python 脚本插件
【发布时间】:2013-03-20 09:04:36
【问题描述】:

我正在尝试在 elasticsearch 中运行一个简单的更新脚本。 它似乎在 mvel 上工作得很好,但在 python 上却不行。

curl -XPOST 'localhost:9200/index1/type1/1/_update?pretty=true' 
-d '{"script" : "ctx._source.myfield=\"item\""}'
{
  "ok" : true,
  "_index" : "index1",
  "_type" : "type1",
  "_id" : "1",
  "_version" : 7
}

curl -XPOST 'localhost:9200/index1/type1/1/_update?pretty=true' 
-d '{"script" : "ctx._source.myfield=\"item\"","lang":"python"}'
{
  "error" : "ElasticSearchIllegalArgumentException[failed to execute script]; nested: NullPointerException; ",
  "status" : 400
}

我的 ES 版本是 0.20.4

我的 elasticsearch-lang-python 插件是 1.1.0(我也试过 1.2.0)

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    在 python 插件中看起来像a bug。您可以添加空参数列表作为解决方法:

    curl -XPOST 'localhost:9200/index1/type1/1/_update?pretty=true' -d '{
        "script": "ctx[\"_source\"][\"myfield\"]=\"foo\"",
        "lang": "python",
        "params": {}
    }'
    

    【讨论】:

      猜你喜欢
      • 2021-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-11
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      相关资源
      最近更新 更多