# Elastic Search nested sets (tree)

**URL:** https://discuss.elastic.co/t/elastic-search-nested-sets-tree/71965
**Category:** Elasticsearch
**Created:** [January 18, 2017, 9:53am UTC](https://discuss.elastic.co/t/elastic-search-nested-sets-tree/71965 "2017-01-18T09:53:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Behemo1h](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/behemo1h/32/130721_2.png) [@Behemo1h](https://discuss.elastic.co/u/Behemo1h)
#### Post date: [January 18, 2017, 9:53am UTC](https://discuss.elastic.co/t/elastic-search-nested-sets-tree/71965/1 "2017-01-18T09:53:04Z")

</div>

Hello everyone.  
I'm a little confused because of a lack of experience and noSQL ES. I hope you will help me to understand in more detail the problem of the organization tree in the ES.

I have two related objects in my project. One object refer to another object which is organized with the help of Nested Sets.

![](https://us1.discourse-cdn.com/elastic/original/2X/5/5c2ce0228ed81715fc216385a2637c2cd0dbb478.png)

If I understand correctly in Elastic Search this would be as follows -

![](https://us1.discourse-cdn.com/elastic/original/2X/9/9703a172a09e4afed7aba07e52f06f9296747010.png)

The problem is that when updating nested sets the table need to be updated lft rgt keys from the entire root (tree in my case), but because Mysql to have foreign keys, I can only update the table that is referenced (nested sets). But to refer to the object in the other table can milion records. It is that if I want to insert a new entity into nested sets I need to fully update all index in the ES ?

Также в основном все операции происходят в mysql но данные для full text поиска храняться в ES, но также я думаю выполнять и поиск по деревьям в ES

---

<div class="post-metadata">

### Author: ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)
#### Post date: [January 18, 2017, 10:43am UTC](https://discuss.elastic.co/t/elastic-search-nested-sets-tree/71965/2 "2017-01-18T10:43:44Z")

</div>

I think you want to take a closer look at how parent child works within Elasticsearch:

[https://www.elastic.co/guide/en/elasticsearch/guide/current/parent-child.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/parent-child.html)

More comprehensive docs on how to handle relationships in ES is available here:

[https://www.elastic.co/guide/en/elasticsearch/guide/current/relations.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/relations.html)

Hope this helps,  
Isabel

---

<div class="post-metadata">

### Author: ![Behemo1h](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/behemo1h/32/130721_2.png) [@Behemo1h](https://discuss.elastic.co/u/Behemo1h)
#### Post date: [January 18, 2017, 11:46am UTC](https://discuss.elastic.co/t/elastic-search-nested-sets-tree/71965/3 "2017-01-18T11:46:30Z")

</div>

Thank you it helpful!

---

<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: [February 15, 2017, 11:46am UTC](https://discuss.elastic.co/t/elastic-search-nested-sets-tree/71965/4 "2017-02-15T11:46:30Z")

</div>

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