# Dictionary in Kibana for translation

**URL:** <https://discuss.elastic.co/t/dictionary-in-kibana-for-translation/112029>\
**Category:** Kibana\
**Created:** [December 15, 2017, 6:00pm UTC](https://discuss.elastic.co/t/dictionary-in-kibana-for-translation/112029 "2017-12-15T18:00:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scch/32/25504_2.png) [@scch](https://discuss.elastic.co/u/scch)\
**Post date:** [December 15, 2017, 6:00pm UTC](https://discuss.elastic.co/t/dictionary-in-kibana-for-translation/112029/1 "2017-12-15T18:00:29Z")

</div>

How to create a dictionary or refer an external csv file to translate and generate scripted fields using painless.

i am aware of similar function in Logstash, grok filter, but need to create scripted field using painless.

thank you...

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [December 22, 2017, 9:31am UTC](https://discuss.elastic.co/t/dictionary-in-kibana-for-translation/112029/2 "2017-12-22T09:31:21Z")

</div>

Hey,

sorry for the very late response.

For security and scaleability reasons, you are not able to access local files or such in Painless scripts, meaning you would need to hardcode that dictionary in your scripted field like:

```auto
def dict = ['key1': 'some-value', 'another-key': 'another-value'];
return dict[doc['your_key_field'].value]

```

If your field can have sparse data or your dictionary might not cover all possible values, you might want to add some `null` checks in the above code.

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![scch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scch/32/25504_2.png) [@scch](https://discuss.elastic.co/u/scch)\
**Post date:** [December 27, 2017, 8:29am UTC](https://discuss.elastic.co/t/dictionary-in-kibana-for-translation/112029/3 "2017-12-27T08:29:18Z")

</div>

Hi Tim,  
This helps and convenient otherwise i hard coded if else construct...

also, can you please point me to some detailed documentation on painless scripting(functions,methods and usage). i am new to to ELK especially for painless scripting and struggling to code even sorting and counting snips.

I tried translating java script snips but failed.

currently looks like it is very painful..  
Can we start new group on painless scripting....?

Thank you....

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [December 29, 2017, 5:58pm UTC](https://discuss.elastic.co/t/dictionary-in-kibana-for-translation/112029/4 "2017-12-29T17:58:11Z")

</div>

Hi,

the official documentation can be found on [elastic.co](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/modules-scripting-painless.html). There is also an API reference available.

Regarding the group. Since Painless is an Elasticsearch build-in feature, I think the best place would be the [Elasticsearch subforum](https://discuss.elastic.co/c/elasticsearch) to ask questions regarding Painless at the moment.

@warkolm Do you think we should create a custom subforum for painless? That way we would have a centralized place to ask and also a better place to look for already existing answers then we have currently?

Cheers,  
Tim

---

<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:** [January 26, 2018, 5:58pm UTC](https://discuss.elastic.co/t/dictionary-in-kibana-for-translation/112029/5 "2018-01-26T17:58:44Z")

</div>

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