I have an index which has a field 'description' with some text. I want to search for a pattern in this field (ex: Error Message: XXXXXXX) and I want to return the text after it but have not been able to accomplish this yet.
I used the code below but the result is not what was expected.
def path = doc['descricao'].value;
int a = path.indexOf("error" );
int b = path.indexOf("Error" );
if (a > 0) { return path.substring(a);}
else if (b > 0) {return path.substring(b);}
else {return "";}
Any ideas of how I can accomplish this?
Aside from the Painless script language, is there any other way to do it?
Thanks.