Unable to split Strings in Painless


(Kaustubh Pardeshi) #1

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?

(David Pilato) #2

Are you doing that in an ingest pipeline ?

(Kaustubh Pardeshi) #3

Im trying to create a scripted field

(David Pilato) #4

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.

(system) closed #5

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