Hi
I'm trying to generate a scripted field that returns only certain tokens of a derived field. For example, if I have a field with possible combination of tokens "Movies, pg13, Drama, comedy, etc" I want to generate a scripted field that only returns the genre tokens (drama, comedy, etc), not the other tokens (pg13, movies, etc). My code to do so is the following:
String r = "";
if (doc['Industry.keyword'].value =~ /drama/) {
r = r + "drama ";
}
if (doc['Industry.keyword'].value =~ /comedy/) {
r = r + "comedy ";
}
return r
This resulted in a "Courier Fetch: 1 of 5 shards failed."
So, I tried simply just writing a script for a field that would return an exact copy of another field. My script is the following:
return doc['Industry.keyword'].value
But it only returns the first token delimited by a comma. So, if a record has the Industry value "Drama, Thriller, Horror," it only returns "Drama." I want it to return the whole string. Any help?