How to get multi valued field values in painless

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!

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.

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