2017-09-04 23 views
1

我想通過命令創建PUT列表,但出現以下錯誤。CURL by commands

代碼:

curl -XPOST http://127.0.0.1:9200/lecordonbleu/documentos/_update_by_query -d '{'script': 'ctx._source.codigoTema = '1' ; ctx._source.tema = 'ACEITES Y GRASAS' ', 'query': {'term' : {'codigoTema' : '66'} } }'; 
curl -XPOST http://127.0.0.1:9200/lecordonbleu/documentos/_update_by_query -d '{'script': 'ctx._source.codigoTema = '2' ; ctx._source.tema = 'ADITIVOS ALIMENTARIOS' ', 'query': {'term' : {'codigoTema' : '67'} } }'; 
curl -XPOST http://127.0.0.1:9200/lecordonbleu/documentos/_update_by_query -d '{'script': 'ctx._source.codigoTema = '3' ; ctx._source.tema = 'ADMINISTRACION' ', 'query': {'term' : {'codigoTema' : '68'} } }'; 

錯誤: Error executing script

應當注意的是,當我感覺運行它我沒有得到任何錯誤,正確更新。 你能幫我或告訴我我失敗了嗎?

非常感謝。

+0

你需要在你的JSON中使用雙引號,否則它將無法工作。 – Val

+0

引號要去哪裏? –

+0

''{「script」:「ctx ._...}''單引號僅用於包裝整個查詢 – Val

回答

1

您的腳本還需要進入"inline"參數。你需要做的是這樣的:

curl -XPOST http://127.0.0.1:9200/lecordonbleu/documentos/_update_by_query -d '{"script": { "inline": "ctx._source.codigoTema = ''1'' ; ctx._source.tema = ''ACEITES Y GRASAS''"}, "query": {"term" : {"codigoTema" : "66"} } }'; 

既然你正在運行ES 1.6,你需要做的是這樣的:

curl -XPOST http://127.0.0.1:9200/lecordonbleu/documentos/_update_by_query -d '{"script": "ctx._source.codigoTema = ''1'' ; ctx._source.tema = ''ACEITES Y GRASAS''", "query": {"term" : {"codigoTema" : "66"} } }'; 

並確保你已經安裝了"update by query" plugin的正確版本

+0

我收到以下錯誤:」error「:」ElasticsearchException [Couldn解析來自源的查詢。];嵌套:JsonParseException [在[VALUE_STRING \ n中的輸入意外結束輸入] [Source:[B @ 47181414;行:1,列:163]]; 「},」1「:... –

+0

{」error「:」ElasticsearchException [無法解析來自源的查詢。嵌套:JsonParseException [在[VALUE_STRING \ n中的輸入意外結束輸入] [Source:[B @ 47181414;行:1,列:163]]; 「} –

+0

我的不好,請檢查我的更新回答。 – Val