# Mapping a Product/Category Tree

**URL:** https://discuss.elastic.co/t/mapping-a-product-category-tree/43816
**Category:** Elasticsearch
**Created:** [March 8, 2016, 6:05pm UTC](https://discuss.elastic.co/t/mapping-a-product-category-tree/43816 "2016-03-08T18:05:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://discuss.elastic.co/u/basti)
#### Post date: [March 8, 2016, 6:05pm UTC](https://discuss.elastic.co/t/mapping-a-product-category-tree/43816/1 "2016-03-08T18:05:59Z")

</div>

Hello together,  
i am new to elastic and just creating a new index for my webshop.  
In this shop i have n categories with n products.  
Each product can have n categories and the categories can have parent categories.

e.g.

category1-\>category2-\>category3-\>product1  
category4-\>category5-\>product1  
category1-\>category6-\>product2

Now I am searching for the best solution to create my index. After indexing my products i want to filter by category and level.

At the moment the best solution for me is:  
create a Index with all category-IDs and parentcategoryIDs in which this product is listed. So i can filter the products.  
e.g.  
product1 =\> cat1,cat2,cat3,cat4,cat5  
product2 =\> cat1, cat6

now i am searching the solution for how to index the categories in my products, so i can show a aggregation of category-tree-name and category-tree-ids.  
So i can show them in json and filter again for the categories.

Perhaps somebody can help me to find the best solution. I searched the web, but cant find a solution which seems to be perfect.

THANKS in advance!!!

---

<div class="post-metadata">

### Author: ![vbura](https://avatars.discourse-cdn.com/v4/letter/v/76d3ee/32.png) [@vbura](https://discuss.elastic.co/u/vbura)
#### Post date: [April 6, 2017, 7:11pm UTC](https://discuss.elastic.co/t/mapping-a-product-category-tree/43816/2 "2017-04-06T19:11:30Z")

</div>

> [@basti](#):
>
> parentcategoryIDs

Did you find any solution?

i found [GitHub - jprante/elasticsearch-aggregations: More aggregations for Elasticsearch](https://github.com/jprante/elasticsearch-aggregations) but is not working with es 5.x

Best regards

---

<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 5, 2017, 10:01pm UTC](https://discuss.elastic.co/t/mapping-a-product-category-tree/43816/3 "2017-07-05T22:01:24Z")

</div>


