# After creating scripted field everything in kibana dashboard disappears?

**URL:** <https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776>\
**Category:** Kibana\
**Created:** [September 25, 2018, 6:42am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776 "2018-09-25T06:42:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pramodchoudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pramodchoudhari/32/126902_2.png) [@pramodchoudhari](https://discuss.elastic.co/u/pramodchoudhari)\
**Post date:** [September 25, 2018, 6:42am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/1 "2018-09-25T06:42:55Z")

</div>

**there is a field named st2 in all the documents as shown below,**  
**the type of st2 field is string,**

 ![Capture3](https://us1.discourse-cdn.com/elastic/original/3X/3/0/303197c735a1b6b4f7f886e1c8ead7a724dbdbc9.png)

**i want to manipulate the field and perform some calculations, so i create a scripted field named RX as shown below**

 ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/c/8/c808ffa8a9e923a8f839cab6087c638357652f06.png)

but after creating scripted field, instead of showing an extra field named **'RX'** , everything on my kibana dashboard disappears.

note:  
**the file from which i am reading is a static file**  
Please Help!!!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 25, 2018, 6:52am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/2 "2018-09-25T06:52:57Z")

</div>

As it is a string I suspect you need to convert it to an integer before you can use it in calculations:

```auto
(Integer.parseInt(doc['st2'].value)*8)/900 

```

---

<div class="post-metadata">

**Author:** ![pramodchoudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pramodchoudhari/32/126902_2.png) [@pramodchoudhari](https://discuss.elastic.co/u/pramodchoudhari)\
**Post date:** [September 25, 2018, 6:57am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/3 "2018-09-25T06:57:48Z")

</div>

still facing the same problem  
do i need to restart ELK stack again?  
also i tried to change the language to expression but i get this error

 ![Screenshot%20(9)](https://us1.discourse-cdn.com/elastic/original/3X/6/1/61d7b0ce10176da1ef14299489e4b7f2d85ebbff.png)

Please help!!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 25, 2018, 7:27am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/4 "2018-09-25T07:27:03Z")

</div>

Assuming you are using default mappings, it should probably look like this:

```auto
(Integer.parseInt(doc['st2.keyword'].value) * 8.0 ) / 900

```

---

<div class="post-metadata">

**Author:** ![pramodchoudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pramodchoudhari/32/126902_2.png) [@pramodchoudhari](https://discuss.elastic.co/u/pramodchoudhari)\
**Post date:** [September 25, 2018, 12:06pm UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/5 "2018-09-25T12:06:08Z")

</div>

what is the difference between st2 and st2.keyword???

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 25, 2018, 1:46pm UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/6 "2018-09-25T13:46:05Z")

</div>

If you are using default mappings `st2` will be analysed and not available as a doc value, which is what you are trying fo access in the script. `st2.keyword` is however stored as doc values, which is why you can access it using the `doc[]` notation.

---

<div class="post-metadata">

**Author:** ![pramodchoudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pramodchoudhari/32/126902_2.png) [@pramodchoudhari](https://discuss.elastic.co/u/pramodchoudhari)\
**Post date:** [September 26, 2018, 5:04am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/7 "2018-09-26T05:04:41Z")

</div>

I tried creating new field today

It's showing me this error today,yesterday it was all fine

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4bcc7476575d90225d2def1434fc4419857a3cc0.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 26, 2018, 5:08am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/8 "2018-09-26T05:08:01Z")

</div>

It looks like either the mapping has changed or that not all documents contain the field. If it is the latter you will need to guard against this in the script.

---

<div class="post-metadata">

**Author:** ![pramodchoudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pramodchoudhari/32/126902_2.png) [@pramodchoudhari](https://discuss.elastic.co/u/pramodchoudhari)\
**Post date:** [September 26, 2018, 5:09am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/9 "2018-09-26T05:09:58Z")

</div>

actually i deleted all the indexes and documets and then created new index today,what should i do?  
Also I cannot see .keyword values for some of the fields in available fields

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 26, 2018, 5:27am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/10 "2018-09-26T05:27:55Z")

</div>

Your mappings or index template will determine whether the keyword subfield exists or not. If not all documents contain the field you may need to try something like this, which return a default value of 0 if the field is not found:

```auto
int val = 0; if(!doc['st2.keyword'].empty) { val = Integer.parseInt(doc['st2.keyword'].value) * 8.0 ) / 900; } return val;

```

Since you know if the field is there at index time, why not create an additional field with the correct value before you index the document. That way you perform the calculation once instead of for every document and every query, which will likely give better performance.

---

<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 24, 2018, 5:28am UTC](https://discuss.elastic.co/t/after-creating-scripted-field-everything-in-kibana-dashboard-disappears/149776/11 "2018-10-24T05:28:00Z")

</div>

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