# How to get multi valued field values in painless

**URL:** <https://discuss.elastic.co/t/how-to-get-multi-valued-field-values-in-painless/147554>\
**Category:** Elasticsearch\
**Created:** [September 6, 2018, 10:58am UTC](https://discuss.elastic.co/t/how-to-get-multi-valued-field-values-in-painless/147554 "2018-09-06T10:58:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chandrapraba](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@chandrapraba](https://discuss.elastic.co/u/chandrapraba)\
**Post date:** [September 6, 2018, 10:58am UTC](https://discuss.elastic.co/t/how-to-get-multi-valued-field-values-in-painless/147554/1 "2018-09-06T10:58:23Z")

</div>

Hi,

I'm new to Elastic Search and Painless. I have a field in my index which has multiple values as shown below.

FieldName Language  
Value "Computer Science"

In painless, When i try to get the value of this field as doc['Language'] - It returns value as ["Computer", "Science"] which is an array.

Is there a option where i can get the value as string than Array?

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [September 6, 2018, 5:23pm UTC](https://discuss.elastic.co/t/how-to-get-multi-valued-field-values-in-painless/147554/2 "2018-09-06T17:23:57Z")

</div>

This will depend on how the mapping of the field is setup. If you don't want the value to be tokenized, set the field type to `keyword`. However, `doc['Language']` will always return a List. You can either just access the first value using `[0]`, or use `.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:** [October 4, 2018, 5:29pm UTC](https://discuss.elastic.co/t/how-to-get-multi-valued-field-values-in-painless/147554/3 "2018-10-04T17:29:33Z")

</div>

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