I am trying to aggregate over dynamic fields (different for different documents) via elasticsearch. Documents are like following:
[{
"name": "galaxy note",
"price": 123,
"attributes": {
"type": "phone",
"weight": "140gm"
}
},{
"name": "shirt",
"price": 123,
"attributes": {
"type": "clothing",
"size": "m"
}
}]
As you can see attributes change across documents. What Im trying to achieve is to aggregate fields of these attributes, like so:
{
aggregations: {
types: {
buckets: [{key: 'phone', count: 123}, {key: 'clothing', count: 12}]
}
}
}
I am trying aggregation feature of elasticsearch to achieve this, but not able to find correct way. Is it possible to achieve via aggregation ? Or should I start looking in to facets, thought it seem to be depricated.