Python client : put_script

Hi,

I'm upgrading our elastic search code to 6.2 and on the python client we use the following API: http://elasticsearch-py.readthedocs.io/en/master/api.html, particularly "put_script". Whereas before we would be able to pass the language in which the script is written as a parameter now I don't find any way of setting that property. I was expecting that if not specified "painless" would be the default value but when posting the script via the python client "mustache" it's actually what seems to be set/defaulted as that's what it's returned on a query to that newly created script from the command line.

e.g.:

curl http://deves.test.aistemos.com:9200/_scripts/size_active_score
{"_id":"size_active_score","found":true,"script":{"lang":"mustache","source":"{"source":"1 + 5 * 1 + doc['size_active'].value\n"}"}}

I wonder if someone knows how is possible to specify the language of the script using the python java client (conn.put_script(...) )? or I would need to change the script to be written in mustache?

Many thanks,
Gemma

I've finally managed by changing the body, initially was just defining the source, but went one level up to include the language:

_conn.put_script(id=script_id, body={'script':{'lang':'painless', 'source': script}})

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.