# Suggestions for storing hierarchical structure

**URL:** <https://discuss.elastic.co/t/suggestions-for-storing-hierarchical-structure/11109>\
**Category:** Elasticsearch\
**Created:** [March 12, 2013, 12:00pm UTC](https://discuss.elastic.co/t/suggestions-for-storing-hierarchical-structure/11109 "2013-03-12T12:00:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sujoysett](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@sujoysett](https://discuss.elastic.co/u/sujoysett)\
**Post date:** [March 12, 2013, 12:00pm UTC](https://discuss.elastic.co/t/suggestions-for-storing-hierarchical-structure/11109/1 "2013-03-12T12:00:33Z")

</div>

Hi,

Looking for suggestions on a business case which is being currently  
addressed to.  
Following is the sample of data we want to store in elasticsearch in  
hierarchical format. It is close to a hierarchical synonym tree.

cine,movies,Entertainment  
film,movies,Entertainment

One option is to store the data in a single ES document, as follows :

{  
"taxonomyName": "Entertainment",  
"taxonomyMembers": [],  
"taxonomyHierarchy": [  
{  
"taxonomyName": "movies",  
"taxonomyMembers": [  
"cine",  
"film"  
],  
"taxonomyHierarchy": []  
}  
]  
}

Another option is to keep each word into separate ES documents, as follows :

{  
"taxonomyName": "Entertainment",  
"taxonomyHierarchy": [  
{  
"taxonomyName": "movies",  
"taxonomyMember": "cine"  
}  
]  
}

and

{  
"taxonomyName": "Entertainment",  
"taxonomyHierarchy": [  
{  
"taxonomyName": "movies",  
"taxonomyMember": "film"  
}  
]  
}

We have dictionary of such words, count reaching up-to several thousands,  
having hierarchy level up to 5 so far.  
We keep on adding/deleting words in bulk from this dictionary, we often  
change hierarchy of several words in bulk.

Which of the above seems to be the better structure to store such data? A  
single large json document containing all words? Or many small json  
documents each with a single word and its hierarchy? Any suggestions?

Thanks,  
-- Sujoy.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 13, 2013, 12:31pm UTC](https://discuss.elastic.co/t/suggestions-for-storing-hierarchical-structure/11109/2 "2013-03-13T12:31:04Z")

</div>

> Which of the above seems to be the better structure to store such  
> data? A single large json document containing all words? Or many  
> small json documents each with a single word and its hierarchy? Any  
> suggestions?

It depends. how do you want to search the data? That really determines  
the best structure for it

clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![sujoysett](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@sujoysett](https://discuss.elastic.co/u/sujoysett)\
**Post date:** [March 13, 2013, 1:14pm UTC](https://discuss.elastic.co/t/suggestions-for-storing-hierarchical-structure/11109/3 "2013-03-13T13:14:13Z")

</div>

Hi,

The requirement is expected to change dynamically .... so hard to tell  
right now 🙂  
Till now, the objective is to achieve a dictionary proliferation mechanism,  
with following functions:

1. Display the data in a tree-view hierarchy.
2. Add/remove more elements at any hierarchy level.
3. Add/remove/edit levels in hierarchy.

Thanks,  
-- Sujoy.

On Wednesday, March 13, 2013 6:01:04 PM UTC+5:30, Clinton Gormley wrote:

> > Which of the above seems to be the better structure to store such  
> > data? A single large json document containing all words? Or many  
> > small json documents each with a single word and its hierarchy? Any  
> > suggestions?
> 
> It depends. how do you want to search the data? That really determines  
> the best structure for it
> 
> clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:46am UTC](https://discuss.elastic.co/t/suggestions-for-storing-hierarchical-structure/11109/4 "2017-07-06T02:46:41Z")

</div>


