# Ecommerce attribute mapping and performance

**URL:** <https://discuss.elastic.co/t/ecommerce-attribute-mapping-and-performance/358616>\
**Category:** Elasticsearch\
**Created:** [May 2, 2024, 8:54am UTC](https://discuss.elastic.co/t/ecommerce-attribute-mapping-and-performance/358616 "2024-05-02T08:54:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cem1835](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cem1835/32/134069_2.png) [@cem1835](https://discuss.elastic.co/u/cem1835)\
**Post date:** [May 2, 2024, 8:54am UTC](https://discuss.elastic.co/t/ecommerce-attribute-mapping-and-performance/358616/1 "2024-05-02T08:54:51Z")

</div>

Hello,

I have been working to map database-based products to elastic index. Our current database is based on Nopcommerce. And all other e-commerce structures, We have dynamic attributes too. That's why for mapping attributes to elastic, I used nested types like the below:

```auto
"attributes": {
        "type": "nested",
        "properties": {
          "name": {
            "properties": {
              "tr": {
                "type": "keyword",
                "ignore_above": 256
              },
              "en": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "values": {
            "type": "nested",
            "properties": {
              "id": {
                "type": "long"
              },
              "text": {
                "properties": {
                  "tr": {
                    "type": "keyword",
                    "ignore_above": 256
                  },
                  "en": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "priceAdjustment": {
                "type": "double"
              }
            }
          },
          "controlType": {
            "type": "keyword"
          },
          "defaultValue": {
            "type": "long"
          },
          "isRequired": {
            "type": "boolean"
          }
        }
      }

```

I store my attributes like size,color,processor type, battery life etc. in this structure. And for showing this attributes with aggregation, I need nested and hierarchical aggregations like the below:

```auto
{
  "size": 0,
  "aggs": {
    "attribute_nested_agg": {
      "nested": {
        "path": "attributes"
      },
      "aggs": {
        "attributes_agg": {
          "terms": {
            "field": "attributes.name.en",
            "size": 10
          },
          "aggs": {
            "attributes_values_nested_agg": {
              "nested": {
                "path": "attributes.values"
              },
              "aggs": {
                "atrributes_values_agg": {
                  "terms": {
                    "field": "attributes.values.text.en",
                    "size": 10
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

```

My questions are:

Is this a good way for doing like that?  
Does it create performance problems?  
Is there an alternative way?

Thanks.
