# Get parent field from join mapping

**URL:** <https://discuss.elastic.co/t/get-parent-field-from-join-mapping/294341>\
**Category:** Elasticsearch\
**Tags:** runtime-fields\
**Created:** [January 13, 2022, 11:26pm UTC](https://discuss.elastic.co/t/get-parent-field-from-join-mapping/294341 "2022-01-13T23:26:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tleduong](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tleduong](https://discuss.elastic.co/u/tleduong)\
**Post date:** [January 13, 2022, 11:26pm UTC](https://discuss.elastic.co/t/get-parent-field-from-join-mapping/294341/1 "2022-01-13T23:26:58Z")

</div>

I have a join mapping relationship where units is the parent and wells is child.

I'm trying to run this query to return the child but also include a field from the parent. This would only return the parent ID. How do i return a field in the parent document called "name"?

```auto
{
  "query": {
    "parent_id": { 
      "type": "wells",
      "id": "units-1"
    }
  },
  "runtime_mappings": {
    "parent": {
      "type": "keyword",
      "script": "emit(doc['my_join_field#units'].value)"
    }
  },   
  "fields": [
    { "field": "parent" }
  ]
}

```

---

<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:** [February 10, 2022, 11:27pm UTC](https://discuss.elastic.co/t/get-parent-field-from-join-mapping/294341/2 "2022-02-10T23:27:19Z")

</div>

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