# Help: In Groovy script function: how can i use doc\['child.field'\] to get the value of child's field in Parent-child Relationship?

**URL:** <https://discuss.elastic.co/t/help-in-groovy-script-function-how-can-i-use-doc-child-field-to-get-the-value-of-childs-field-in-parent-child-relationship/156813>\
**Category:** Elasticsearch\
**Created:** [November 15, 2018, 8:55am UTC](https://discuss.elastic.co/t/help-in-groovy-script-function-how-can-i-use-doc-child-field-to-get-the-value-of-childs-field-in-parent-child-relationship/156813 "2018-11-15T08:55:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![balancebug](https://avatars.discourse-cdn.com/v4/letter/b/839c29/32.png) [@balancebug](https://discuss.elastic.co/u/balancebug)\
**Post date:** [November 15, 2018, 8:55am UTC](https://discuss.elastic.co/t/help-in-groovy-script-function-how-can-i-use-doc-child-field-to-get-the-value-of-childs-field-in-parent-child-relationship/156813/1 "2018-11-15T08:55:48Z")

</div>

in groovy script,  
how can i use doc['child.field'] to get the value of child's field in Parent-child Relationship?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [November 15, 2018, 10:57pm UTC](https://discuss.elastic.co/t/help-in-groovy-script-function-how-can-i-use-doc-child-field-to-get-the-value-of-childs-field-in-parent-child-relationship/156813/2 "2018-11-15T22:57:00Z")

</div>

Child docs cannot be accessed from a parent doc, as they are separate documents in Lucene. Depending on the type of script, you can look at the original document through `_source`, but note that this can be very slow as it means a disk load + json parsing.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 13, 2018, 10:57pm UTC](https://discuss.elastic.co/t/help-in-groovy-script-function-how-can-i-use-doc-child-field-to-get-the-value-of-childs-field-in-parent-child-relationship/156813/3 "2018-12-13T22:57:02Z")

</div>

Closed on December 13, 2018, 10:57pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
