# String Scripted field conversion to keyword

**URL:** <https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531>\
**Category:** Kibana\
**Created:** [May 10, 2021, 5:03am UTC](https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531 "2021-05-10T05:03:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SHUBHAM\_SALUNKHE](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_salunkhe/32/81258_2.png) [@SHUBHAM\_SALUNKHE](https://discuss.elastic.co/u/SHUBHAM_SALUNKHE)\
**Post date:** [May 10, 2021, 5:03am UTC](https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531/1 "2021-05-10T05:03:13Z")

</div>

Hi,  
I have created one scripted field of string format. Need to convert that in keyword format to perform aggregation operation on that scripted field. How can I convert that string?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [May 10, 2021, 6:12am UTC](https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531/2 "2021-05-10T06:12:48Z")

</div>

Scripted fields are always aggregatable - keyword vs. text fields are only a concept of indexed fields in Elasticsearch, not for scripted fields in Kibana. Those are always of type "string".

---

<div class="post-metadata">

**Author:** ![SHUBHAM\_SALUNKHE](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_salunkhe/32/81258_2.png) [@SHUBHAM\_SALUNKHE](https://discuss.elastic.co/u/SHUBHAM_SALUNKHE)\
**Post date:** [May 10, 2021, 7:14am UTC](https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531/3 "2021-05-10T07:14:52Z")

</div>

Hi @flash1293 ,  
I am trying same scripted field in TSVB table for group by operation. but it is not displaying anything in table. So do i need to convert that field in any other format? if yes, please give solution.

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [May 10, 2021, 7:16am UTC](https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531/4 "2021-05-10T07:16:16Z")

</div>

- Did you make sure the scripted field works as expected (e.g. by looking at the values in Discover)?
- Does the table show any data if grouping by another field?

---

<div class="post-metadata">

**Author:** ![SHUBHAM\_SALUNKHE](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_salunkhe/32/81258_2.png) [@SHUBHAM\_SALUNKHE](https://discuss.elastic.co/u/SHUBHAM_SALUNKHE)\
**Post date:** [May 11, 2021, 5:31am UTC](https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531/5 "2021-05-11T05:31:53Z")

</div>

Hi @flash1293 ,  
scripted field works as expected & grouping on other field is possible. I have added that field in filebeat while loading data in logstash only. Now that issue it solved.

---

<div class="post-metadata">

**Author:** ![SHUBHAM\_SALUNKHE](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_salunkhe/32/81258_2.png) [@SHUBHAM\_SALUNKHE](https://discuss.elastic.co/u/SHUBHAM_SALUNKHE)\
**Post date:** [May 11, 2021, 5:35am UTC](https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531/6 "2021-05-11T05:35:40Z")

</div>

Hi @flash1293 ,  
One more issue is there. I am trying to set colors to pie-chart while creating pie-chart on basis of field value like if "Success" then set that slice color to green & if it is "Failed" then setting other slice to "Red". but colors updated with some random colors after some time. How to fix color for pie-chart based on Field value?

---

<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 8, 2021, 5:35am UTC](https://discuss.elastic.co/t/string-scripted-field-conversion-to-keyword/272531/7 "2021-06-08T05:35:41Z")

</div>

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