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;
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
To view this discussion on the web visit
For more options, visit