Groovy script to iterate through nested object for scoring throws error

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 ? Please let me knwo what do you think @nik9000