This script below works fine but I would like to insert an IF statement that executes these lines of code only in the case a third '_' character is present in the field 'measurement', otherwise it does not execute anything.
def AB = doc['measurement'].value.splitOnToken('_');
return AB[3].substring(0, 5);
In your script the statment indexOf('_') look like always returns the number 7 which is the position of the first underline.
In the field measurement there are strings which contain more than one char '_' but only if it finds a third underline, it retrieve the next 5 characters.
i.e. In the first string, the script does not do anything because a third '_' underline doesn't exist, while in the second string it will extract CSCDS and in the third one it will extract CSHHD
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.