# ES6 parent-child join - how do you specify the child doc schema?

**URL:** <https://discuss.elastic.co/t/es6-parent-child-join-how-do-you-specify-the-child-doc-schema/157632>\
**Category:** Elasticsearch\
**Created:** [November 21, 2018, 7:03am UTC](https://discuss.elastic.co/t/es6-parent-child-join-how-do-you-specify-the-child-doc-schema/157632 "2018-11-21T07:03:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Weisburd](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Ben\_Weisburd](https://discuss.elastic.co/u/Ben_Weisburd)\
**Post date:** [November 21, 2018, 7:03am UTC](https://discuss.elastic.co/t/es6-parent-child-join-how-do-you-specify-the-child-doc-schema/157632/1 "2018-11-21T07:03:09Z")

</div>

In the "question"/"answer" example on  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html)  
the parent and child docs have the same schema (a single field called "text").

In my case, the parent docs have one set of fields and child docs have a different set. I'm currently specifying the parent doc schema with:

```auto
"mappings": {
    "properties": {
          "field1": {
            "type": "long"
          },
          "field2": {
            "type": "keyword"
          },
          "field3": {
            "type": "keyword"
          },
          "join_field": {
            "type": "join",
            "eager_global_ordinals": true,
            "relations": {
              "parent_doc_name": "child_doc_name"
            }
        },
   }
}

```

how can I also specify the child doc schema?

---

<div class="post-metadata">

**Author:** ![loren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loren/32/44942_2.png) [@loren](https://discuss.elastic.co/u/loren)\
**Post date:** [November 21, 2018, 8:11pm UTC](https://discuss.elastic.co/t/es6-parent-child-join-how-do-you-specify-the-child-doc-schema/157632/2 "2018-11-21T20:11:08Z")

</div>

I believe there is only one schema here. The parent and child documents will have the same properties. In your case, you'd need to include both sets of fields in the schema, and leave various fields empty as needed.

You may have a better outcome with an array of `nested` child objects inside the parent doc, or even just maintaining a parent index and a child index, and dealing with the simple join logic yourself. Good luck!

---

<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 19, 2018, 8:11pm UTC](https://discuss.elastic.co/t/es6-parent-child-join-how-do-you-specify-the-child-doc-schema/157632/3 "2018-12-19T20:11:12Z")

</div>

Closed on December 19, 2018, 8:11pm UTC

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