Issues when 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 this?

--
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/904247f3-5df0-4b1d-b509-80d4d606745b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi ,

What is terms here ?
As far as i know , there is no provisions to get all terms for a field for
a document by default.
Only work around is to use term vectors
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-advanced-scripting.html#_term_vectors
.

Thanks
Vineeth Mohan,
Elasticsearch consultant,
qbox.io ( Elasticsearch service provider http://qbox.io/)

On Wed, Jan 28, 2015 at 9:14 AM, Panzer appythoncheck@gmail.com wrote:

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 this?

--
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/904247f3-5df0-4b1d-b509-80d4d606745b%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/904247f3-5df0-4b1d-b509-80d4d606745b%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CAGdPd5kCxRwZoyMoM%3D0NZ8vKiHqXSKm0DrT9wuEmGRaRh8W5BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Hello @vineeth_mohan_2

I have stored the term vectors still I am facing the below issue:

nested: GroovyScriptExecutionException[MissingPropertyException[No such property: terms for class: 6f0f3a10c46d99c0dac250c63bc1db72285438d4]];

Can you please help ?

Thanks
Siddharth