# Groovy script to iterate through nested object for scoring throws error

**URL:** <https://discuss.elastic.co/t/groovy-script-to-iterate-through-nested-object-for-scoring-throws-error/63904>\
**Category:** Elasticsearch\
**Created:** [October 25, 2016, 4:16pm UTC](https://discuss.elastic.co/t/groovy-script-to-iterate-through-nested-object-for-scoring-throws-error/63904 "2016-10-25T16:16:56Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![pungent](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@pungent](https://discuss.elastic.co/u/pungent)\
**Post date:** [October 25, 2016, 6:11pm UTC](https://discuss.elastic.co/t/groovy-script-to-iterate-through-nested-object-for-scoring-throws-error/63904/5 "2016-10-25T18:11:03Z")

</div>

By the way `"script": "doc['mygroup'].values....` \< i think I cannot use `doc` here. It should be `"script": "_source['mygroup'].values` per [ElasticSearch: access document nested value in groovy script](https://discuss.elastic.co/t/elasticsearch-access-document-nested-value-in-groovy-script/21644) ? Please let me knwo what do you think @nik9000

---

_[View the full topic](https://discuss.elastic.co/t/groovy-script-to-iterate-through-nested-object-for-scoring-throws-error/63904)._
