Painless - check if string contains word

Is it possible to check if a string contains the word in a nested array? I am accessing the fields through params._source and I have created a painless script as below, but it's throwing me errors at contains(). How to check f string contains a word with params._source using contains()?

"script_fields": {
	"recency": {
		"script": {
			"lang": "painless",
			"inline": """
				def myString = "";
				def isCurrent = 0;
				def list = new ArrayList();
				for(int i=0; i<params._source.candidate.work_exp.size(); i++){
					myString = params._source.candidate.work_exp[i].description;
					return list;
			"params": {
				"search_keywords": keywords


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