Large scripted field

I created a scripted field with lots of if statements, which looks like this:

def status = doc['TTS_Verantwortlicher'].value;
if (status == 2) return 'Kirschner' ;
if (status == 4) return 'Gehr' ;
if (status == 5) return 'Grande' ;
if (status == 8) return 'Scheibli' ;
if (status == 10) return 'Meier' ;
if (status == 11) return 'Scalegno' ;
. . .
if (status == 6972) return 'Jurt' ;

Now I get a compile error of Kibana when I click on the discover tab. Is it because of the many if statements and if yes how can I change it? I can't however add a field or change it, as it has to stay as it is.

This in my opinion looks like something that would better be added at ingestion time or through reindexing of the data.

How would it be possible to reindex these fields, with the change from a number to the matching string?

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