# Best design for product attributes

**URL:** <https://discuss.elastic.co/t/best-design-for-product-attributes/46854>\
**Category:** Elasticsearch\
**Created:** [April 9, 2016, 1:35am UTC](https://discuss.elastic.co/t/best-design-for-product-attributes/46854 "2016-04-09T01:35:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zuninet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zuninet/32/9020_2.png) [@zuninet](https://discuss.elastic.co/u/zuninet)\
**Post date:** [April 9, 2016, 1:35am UTC](https://discuss.elastic.co/t/best-design-for-product-attributes/46854/1 "2016-04-09T01:35:20Z")

</div>

I'm indexing products who have myriad of attributes with different types, my first iteration was to store the attributes as a nested type and put the attribute name in a field called key and the value in a field called value. This works fine, except the values are all strings. There is some desire to have the value as the type it was in the json document. What's the best way to map something like this?

Example:

attributes: {  
color: 'red',  
voltage: 12.0  
portable: true  
}

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 9, 2016, 7:04am UTC](https://discuss.elastic.co/t/best-design-for-product-attributes/46854/2 "2016-04-09T07:04:32Z")

</div>

Create a mapping/template for it in ES before indexing is the best way.

---

<div class="post-metadata">

**Author:** ![zuninet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zuninet/32/9020_2.png) [@zuninet](https://discuss.elastic.co/u/zuninet)\
**Post date:** [April 9, 2016, 1:30pm UTC](https://discuss.elastic.co/t/best-design-for-product-attributes/46854/3 "2016-04-09T13:30:27Z")

</div>

I already a mapping template, what I want to know is what it should look like if I want to achieve dynamic types, preferably a nested type for the attributes then automatically generate the key values dynamically with the proper inferred types.

---

<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, 11:00pm UTC](https://discuss.elastic.co/t/best-design-for-product-attributes/46854/4 "2017-07-05T23:00:57Z")

</div>


