2013-03-19 37 views
1

我想在elasticsearch中運行一個簡單的更新腳本。 它似乎與mvel很好地工作,但不與python。彈性搜索python腳本插件更新API

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琅蟒蛇插件1.1.0(我也試圖與1.2.0)

回答

1

它看起來像a bug在Python插件。您可以添加空參數列表作爲解決方法:

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

謝謝!有效!!!! – eran 2013-03-20 07:43:08