Unable to split Strings in Painless

Hi, I am having trouble splitting a string using painless to create a new field. I have a string like:
doc['path.keyword'].value = 'N:/divtaxbacktest/Comp/divbacktest/SMEA.L.csv';

And I would like to extract SMEA.L, so I am trying to first split the string and use substring as such:
String parts = ///.split(doc['path'].value);
return parts[3].substring( 0, -4 );

But it is not working. Could someone please help?

Are you doing that in an ingest pipeline ?

Im trying to create a scripted field

Ok. Please be aware that it will be slow in comparison of doing that at index time (using ingest or not).

May I ask what is your goal at the end?

Also could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

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