# Help in 'painless scripted field creation'

**URL:** <https://discuss.elastic.co/t/help-in-painless-scripted-field-creation/147222>\
**Category:** Kibana\
**Created:** [September 4, 2018, 1:51pm UTC](https://discuss.elastic.co/t/help-in-painless-scripted-field-creation/147222 "2018-09-04T13:51:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roni\_Saha](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@Roni\_Saha](https://discuss.elastic.co/u/Roni_Saha)\
**Post date:** [September 4, 2018, 1:51pm UTC](https://discuss.elastic.co/t/help-in-painless-scripted-field-creation/147222/1 "2018-09-04T13:51:51Z")

</div>

Hello anyone,

I am facing some issue while create a 'Painless Scripted field' ?

Here's the Logs in JSON format -

{  
"\_index": "my-log-test",  
"\_type": "doc",  
"\_version": 1,  
"\_source": {  
"SubType": "000",  
"Time": "10:40:43",  
"Date": "04/09/18",  
"CopID": "001",  
"Type": "000",  
"@timestamp": "2018-09-04T10:40:43.000Z",  
"text": "Payment success, **total\_payments** =000001 , **amount** =1234 ||",  
"Cat": "LOG",  
"system-topic": {  
"topic": "log.my-log-test.tech"  
}  
}

- How I create scripted field named **_total\_payments_** and **_amount_** as type INTEGER

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [September 4, 2018, 6:50pm UTC](https://discuss.elastic.co/t/help-in-painless-scripted-field-creation/147222/2 "2018-09-04T18:50:10Z")

</div>

Hey @Roni_Saha, you can do this using [Regular Expressions](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-examples.html#modules-scripting-painless-regex) in Painless Scripted fields. However, this will be rather slow and resource intensive, and depending on the size of your data you might want to do so during index using Logstash.

---

<div class="post-metadata">

**Author:** ![Roni\_Saha](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@Roni\_Saha](https://discuss.elastic.co/u/Roni_Saha)\
**Post date:** [September 5, 2018, 9:51am UTC](https://discuss.elastic.co/t/help-in-painless-scripted-field-creation/147222/3 "2018-09-05T09:51:27Z")

</div>

Thanks Brandon,

I am aware of the "index using Logstash" that are suggested by you. But the problem is to define field during indexing is that I have thounds of such different patterns!

I will try REGEX and monitor the performance [because in some cases Auto-Refresh would be 1-5 minutes].

---

<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:** [October 3, 2018, 9:51am UTC](https://discuss.elastic.co/t/help-in-painless-scripted-field-creation/147222/4 "2018-10-03T09:51:29Z")

</div>

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