# ElasticSearch 6 recursive

**URL:** <https://discuss.elastic.co/t/elasticsearch-6-recursive/144814>\
**Category:** Elasticsearch\
**Created:** [August 17, 2018, 3:58am UTC](https://discuss.elastic.co/t/elasticsearch-6-recursive/144814 "2018-08-17T03:58:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![naresh236](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@naresh236](https://discuss.elastic.co/u/naresh236)\
**Post date:** [August 17, 2018, 3:58am UTC](https://discuss.elastic.co/t/elasticsearch-6-recursive/144814/1 "2018-08-17T03:58:39Z")

</div>

Please give me a suggestion to how we can implement recursive functionality in Elastic search 6  
i am new to elastic search  
I am having a below calss  
public class Employee  
{  
public int Emp\_Id { get; set; }  
public string Emp\_Name { get; set; }  
[Nested]  
public Employee manager { get; set; }  
}  
data will be

| Emp\_Id | Emp\_Name | Manager\_id |
| --- | --- | --- |
| 1 | a | null |
| 2 | b | 1 |
| 3 | c | 2 |
| 4 | d | 3 |

Here manager Id and employee id is are self join as parent child

My questions are below

1. how can i create an index for above class and how can i insert data.  
2.after creating index, i need to search for employee and i should get the results like recursive  
as it is a self join  
i need result like below when we search for the employee id 4  
{  
"Emp\_Id": 4,  
"Emp\_Name": "d",  
"address": null,  
"manager": {  
"Emp\_Id": 3,  
"Emp\_Name": "c",  
"manager": {  
"Emp\_Id": 2,  
"Emp\_Name": "b",  
"manager": {  
"Emp\_Id": 1,  
"Emp\_Name": "a",  
"manager": null  
}  
}  
}  
}

Is it possible to get the result like this ?

---

<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:** [September 14, 2018, 3:58am UTC](https://discuss.elastic.co/t/elasticsearch-6-recursive/144814/2 "2018-09-14T03:58:46Z")

</div>

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