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

In the "question"/"answer" example on
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:

"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?

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!

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