Problem when looping over an array with objects

Hi!

I'm trying to create a script_field by looping over an array of
values. This works
great with arrays with only ordinary items (e.g. integers or strings)
but I can't figure out how to loop over an array
of objects with properties.

When I try to loop over an array of objects I get this error back:
CompileException[[Error: No field found for [weights]]\n[Near : {...
tmp = ''; for(item : doc['weig ....}]\n
^\n[Line: 1, Column: 1]]; nested:
ElasticSearchIllegalArgumentException[No field found for [weights]];

My example code, requests and return values can be found here:


Stack trace from Elastic: https://gist.github.com/1414981

Tested in both ES 0.17.7 and 0.18.5
I'm using mvel as scripting language.

Is this a bug or i'm using the foreach-loop wrong?

//Patrik

If you are using doc[...] notation, then it loads up the indexed terms from
the Lucene index, in this case, you need to point to actual field elements
indexed in Lucene, for example: weights.lang. Note, if you use
script_fields, it makes little sense to use the doc notation cause it will
cause all values to be loaded, use _source.weights which will load the
_source of the relevant hit and parse it.

On Thu, Dec 1, 2011 at 10:51 AM, Patrik Johansson <
patrik.j.johansson@kentor.se> wrote:

Hi!

I'm trying to create a script_field by looping over an array of
values. This works
great with arrays with only ordinary items (e.g. integers or strings)
but I can't figure out how to loop over an array
of objects with properties.

When I try to loop over an array of objects I get this error back:
CompileException[[Error: No field found for [weights]]\n[Near : {...
tmp = ''; for(item : doc['weig ....}]\n
^\n[Line: 1, Column: 1]]; nested:
ElasticSearchIllegalArgumentException[No field found for [weights]];

My example code, requests and return values can be found here:
Problem when looping over arrays with objects · GitHub
Stack trace from Elastic: https://gist.github.com/1414981

Tested in both ES 0.17.7 and 0.18.5
I'm using mvel as scripting language.

Is this a bug or i'm using the foreach-loop wrong?

//Patrik