David Pineda Canales
David Pineda Canales

Reputation: 19

CURL by commands

I want to make a PUT list by command but I get the following error.

Code:

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: Error executing script

It should be noted that when I run it in Sense I do not get any errors, updating correctly. Could you help me or tell me what I'm failing?

Thank you very much.

Upvotes: 1

Views: 203

Answers (1)

Val
Val

Reputation: 217554

Your script also needs to go into the "inline" parameter. You need to do it like this:

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"} } }';

Since you're running ES 1.6, you need to do it like this:

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"} } }';

And make sure you have installed the proper version of the "update by query" plugin

Upvotes: 1

Related Questions