Scripting with ES - size of array of objects

Hi, everyone.

I'm currently facing a problem I can't seem to solve by myself, so, I came
to seek the help of ES users more seasoned than I happen to be.

I need to calculate the max size or a nested array of objects apprearing in
my docs.

So, I'm using a statistical facet like this one :

{
"query" : {
"match_all" : {}
},
"facets" : {
"stat1" : {
"statistical" : {
"script" : "doc['path_to_nested_object'].values.size()"
}
}
}
}

this gives me an error, witch seems to be normal because I can only use
that script on leaf nodes. So, I do something like this :

{
"query" : {
"match_all" : {}
},
"facets" : {
"stat1" : {
"statistical" : {
"script" : "doc['path-to_nested_object.code'].values.size()"
}
}
}
}

This gives me a result, where the "max" value of the facet should be what
I'm looking for.

BUT !

It seems that when the script runs, it counts the distinct values, and not
all the values. In my example, several of those nested objects have the
same code, within the same doc.

Problem is, a disctinct value count is utterly useless to me.

I really need to count either

  1. the size of the array of objects (that would be the best)
  2. the size of the array of the values of a leaf node within the nested
    object, reapeted values included.

Is one of these possible?
Using another language than mvel?
Using native java scripting, maybe? (any exemple of that one would be
GREATLY appreciated).

Thanks !

--
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/0478dc4d-3976-4f7e-97ae-18fc9645560a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No one met that kind of problems?

--
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/49c9cf7c-6dab-444d-a426-64c3086e6419%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.