Issues while running Groovy script for "function_score"?

def score = 0;
// terms: list of tokens
for(term in terms) {
q_term_freq = terms​.countBy { it }​[term];
term_freq = _index[field][term].tf();
doc_freq = _index[field][term].df();
score += term_freq * doc_freq * q_term_freq;
};
score;
The first one gives an error
"GroovyScriptExecutionException[MissingPropertyException[No such property:
terms\u200b for class: Script86". "q_term_freq" gives a mapping for a term
to its frequency.

How should I correct them?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c90e889a-f442-46b3-8132-f31be13a58f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.