Troubles accessing an object array in a nested element with a script

Hi all,

I am trying to define a range facet on a value of a nested element that is
calculated by a script.
I have an object where level1Array is nested:
{ "a":{ "value":8 , "b":"xxx" }, "c":"zzz" },
{ "a":{ "value":13 , "b":"yyy"}, "c":"www" }

The value of the elevel1Array element used in the range facet is determined
by processing it's level2Array (evaluating b and c fields) and taking
a.value of the chosen object from level2Array.
My request looks something like this:

"query": {
"match_all": {}
"facets": {
"range1": {
"nested": "level1Array",
"range": {
"key_script": "l2Array = _source.level1Array.level2Array;
"value_script": "1",
"ranges": [
"from": 0,
"to": 10
"from": 10,
"to": 20

The request does work if the facet is not nested and I access the array
through _source. My problem is that when the range facet is nested I can
only access simple level1Array elements with doc['fieldName'].value but
doc['level1Array.level2Array'].value does not work becasue level2Array is
object array. I could not access the array through _source when using
nested facet. Is there a way to access my level2Array in a script when
doing nested faceting?


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
For more options, visit