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:
"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:
{
"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.