# Parent/User Relationship using Join type

**URL:** https://discuss.elastic.co/t/parent-user-relationship-using-join-type/153346
**Category:** Elasticsearch
**Created:** [October 22, 2018, 8:35am UTC](https://discuss.elastic.co/t/parent-user-relationship-using-join-type/153346 "2018-10-22T08:35:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ravituvar](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@ravituvar](https://discuss.elastic.co/u/ravituvar)
#### Post date: [October 22, 2018, 8:35am UTC](https://discuss.elastic.co/t/parent-user-relationship-using-join-type/153346/1 "2018-10-22T08:35:35Z")

</div>

I have list of users and there is one field called parent, some users might not have parents.

I want to get the full parent hierarchy, full child hierarchy for given user id.

What should by my mapping on that?

Here is the example.  
**UserId, Name, ParentId**  
1 . , KP . , NULL/Blank/0  
2 . , RT . , 1  
3 . , TH . , 2  
4 . , MS , 3

If I want to get all child hierarchy of UserId-2 that should be Ids (3,4,....) and i also want to get the Parent hierarchy of 4 that should be (3,2,1...!).

Is it possible to achieve this in ES6.3? If yes, what should be my Mapping? I might have Single/Multiple Parents.

---

<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: [November 19, 2018, 8:37am UTC](https://discuss.elastic.co/t/parent-user-relationship-using-join-type/153346/2 "2018-11-19T08:37:51Z")

</div>

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