I am trying to aggregate over dynamic fields (different for different documents) via elasticsearch. Documents are like following:
[{
\"name\": \"galaxy no
Not sure if this is what you mean, but this is fairly simple with basic aggregation functionality. Beware I did not include a mapping so with type of multiple words you are getting double results.
POST /product/atype
{
"name": "galaxy note",
"price": 123,
"attributes": {
"type": "phone",
"weight": "140gm"
}
}
POST /product/atype
{
"name": "shirt",
"price": 123,
"attributes": {
"type": "clothing",
"size": "m"
}
}
GET /product/_search?search_type=count
{
"aggs": {
"byType": {
"terms": {
"field": "attributes.type",
"size": 10
}
}
}
}