Scripted metric aggregation over nested docs

I'm trying to do scripted metric aggregation
http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations-metrics-scripted-metric-aggregation.html
using Groovy with Elasticsearch 1.4.4
I've a document model where each parent document can have 0-n nested
documents and I need to list distinct values and count their occurrences.

How can I access nested document field values in a script?
With this map_script fragment:
for (r in doc['_source.nested']) { _agg.agg.add('abc') }

I get an error saying:
"No field found for [_source.nested] in mapping with types [foo]"

I've also tried omitting "_source" from the field name and also doing a
doc.containsKey check for the field but neither seem to work.

marko

--
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/dc2ea339-f088-49b1-9dd9-1a428f28155b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.