我正在尝试在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)
答案 0 :(得分:1)
在python插件中看起来像a bug。您可以添加空参数列表作为解决方法:
curl -XPOST 'localhost:9200/index1/type1/1/_update?pretty=true' -d '{
"script": "ctx[\"_source\"][\"myfield\"]=\"foo\"",
"lang": "python",
"params": {}
}'