I am trying to create sub aggregations that will return the number of items in each category. For example:
{
"aggs":{
"stores":{
"terms":{
"field": "store_code",
"order": {
"_term": "asc"
}
},
"aggs":{
"item_count":{
"cardinality":{
"field": "items"
}
}
},
"aggs":{
"item_count":{
"cardinality":{
"field": "franchises"
}
}
}
}
}
So the end product should be the store_code's number of distinct items and franchises. However, I get an error saying duplicate key aggs. How can I make it so the sub aggregations display?