# Python client : put\_script

**URL:** https://discuss.elastic.co/t/python-client-put-script/126740
**Category:** Elasticsearch
**Created:** [April 4, 2018, 12:46pm UTC](https://discuss.elastic.co/t/python-client-put-script/126740 "2018-04-04T12:46:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gemma\_Cabero](https://avatars.discourse-cdn.com/v4/letter/g/a88e4f/32.png) [@Gemma\_Cabero](https://discuss.elastic.co/u/Gemma_Cabero)
#### Post date: [April 4, 2018, 12:46pm UTC](https://discuss.elastic.co/t/python-client-put-script/126740/1 "2018-04-04T12:46:05Z")

</div>

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](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](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

---

<div class="post-metadata">

### Author: ![Gemma\_Cabero](https://avatars.discourse-cdn.com/v4/letter/g/a88e4f/32.png) [@Gemma\_Cabero](https://discuss.elastic.co/u/Gemma_Cabero)
#### Post date: [April 4, 2018, 3:45pm UTC](https://discuss.elastic.co/t/python-client-put-script/126740/2 "2018-04-04T15:45:12Z")

</div>

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}})

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 2, 2018, 3:45pm UTC](https://discuss.elastic.co/t/python-client-put-script/126740/3 "2018-05-02T15:45:50Z")

</div>

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