# Join relationship using Elasticsearch client interface

**URL:** <https://discuss.elastic.co/t/join-relationship-using-elasticsearch-client-interface/209347>\
**Category:** Elasticsearch\
**Created:** [November 25, 2019, 4:51pm UTC](https://discuss.elastic.co/t/join-relationship-using-elasticsearch-client-interface/209347 "2019-11-25T16:51:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chari](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@chari](https://discuss.elastic.co/u/chari)\
**Post date:** [November 25, 2019, 4:51pm UTC](https://discuss.elastic.co/t/join-relationship-using-elasticsearch-client-interface/209347/1 "2019-11-25T16:51:07Z")

</div>

I am looking for any examples that implement parent-child relationship using the python interface.  
I can define a mapping such as

```
    es.indices.create(
      index= "docpage",
      body= {
        "mappings": {
            "properties": {
             "my_join_field": { 
               "type": "join",
               "relations": {
                 "document": "page" 
               }
             }
            }
          }
        }
    )

```

I am then indexing a document using  
res = es.index(index="docpage",doc\_type="\_doc",id = 1, body=jsonDict) , where jsonDict is a dict structure of document's text and other relevant info.

How do I then index a page in the document ?  
When I try  
res = es.index(index="docpage",doc\_type="\_doc",parent=1, body=page)  
I get an error : RequestError(400, 'illegal\_argument\_exception', 'request [/docpage/\_doc] contains unrecognized parameter: [parent]')

Ref. [https://elasticsearch-py.readthedocs.io/en/master/api.html](https://elasticsearch-py.readthedocs.io/en/master/api.html) indicates that parent is a valid parameter.  
I see that I am not providing ES with any info about document or a page when I index them.

---

<div class="post-metadata">

**Author:** ![chari](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@chari](https://discuss.elastic.co/u/chari)\
**Post date:** [November 25, 2019, 5:24pm UTC](https://discuss.elastic.co/t/join-relationship-using-elasticsearch-client-interface/209347/2 "2019-11-25T17:24:50Z")

</div>

Following the example in [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-parent-id-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-parent-id-query.html), I tried adding  
jsonDict['my\_join\_field']= 'document'

and a pageDict where,

pageDict['content']=page  
pageDict['my\_join\_field']={}  
pageDict['my\_join\_field']['parent']="1"  
pageDict['my\_join\_field']['name']="page"

res = es.index(index="docpage",doc\_type="\_doc",body=pageDict) , but I get a parser error.....

---

<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 23, 2019, 5:24pm UTC](https://discuss.elastic.co/t/join-relationship-using-elasticsearch-client-interface/209347/3 "2019-12-23T17:24:55Z")

</div>

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