Best design for product attributes

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
}

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

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.