# How to define scripted fields using scripts

**URL:** <https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101>\
**Category:** Kibana\
**Created:** [April 16, 2018, 5:41am UTC](https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101 "2018-04-16T05:41:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![meetdave2611997](https://avatars.discourse-cdn.com/v4/letter/m/f07891/32.png) [@meetdave2611997](https://discuss.elastic.co/u/meetdave2611997)\
**Post date:** [April 16, 2018, 5:41am UTC](https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101/1 "2018-04-16T05:41:26Z")

</div>

I have more than 10 scriped fields in kibana. i want to define each and every scripted field as we do in kibana but using some python or shell scripts. How can i achieve that?

Thank You,  
Meet

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 16, 2018, 6:32am UTC](https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101/2 "2018-04-16T06:32:25Z")

</div>

I don't know specifically for python but here is the REST call: [https://www.elastic.co/guide/en/elasticsearch/reference/6.2/search-request-script-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/search-request-script-fields.html)

---

<div class="post-metadata">

**Author:** ![meetdave2611997](https://avatars.discourse-cdn.com/v4/letter/m/f07891/32.png) [@meetdave2611997](https://discuss.elastic.co/u/meetdave2611997)\
**Post date:** [April 16, 2018, 7:23am UTC](https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101/3 "2018-04-16T07:23:32Z")

</div>

Currently i have 10 painless scripts in txt files and some visualizations and dashboards in json file. I want to create one simple script which automatically creates index-pattern, upload json files for visualizations and dashboards and define scripted fields specified in txt files.

If there is no way to define index-pattern and upload json files using script that is okay. But i want to automate this adding scripted fields so that there is no need to define each and every fields using kibana interface

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 16, 2018, 8:00am UTC](https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101/4 "2018-04-16T08:00:51Z")

</div>

So it's a Kibana question. Moving it to #kibana

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [April 16, 2018, 2:10pm UTC](https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101/5 "2018-04-16T14:10:49Z")

</div>

You could do this REST call after having created a scripted field in Kibana UI:  
`GET .kibana/_search`  
This will show you how the scripted fields are stored in the index pattern document. You can then edit that document with all the scripted fields you wish to add and then update the document in Elasticsearch.

---

<div class="post-metadata">

**Author:** ![meetdave2611997](https://avatars.discourse-cdn.com/v4/letter/m/f07891/32.png) [@meetdave2611997](https://discuss.elastic.co/u/meetdave2611997)\
**Post date:** [May 8, 2018, 11:11am UTC](https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101/6 "2018-05-08T11:11:46Z")

</div>

Thanks

---

<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:** [June 5, 2018, 11:19am UTC](https://discuss.elastic.co/t/how-to-define-scripted-fields-using-scripts/128101/7 "2018-06-05T11:19:10Z")

</div>

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