{
"brands": [
  {
    "value": "brand1"
  },
  {
    "value": "brand1"
  },
  {
    "value": "brand2"
  }
],
"count": 3,
"name": "Windows"
}
I have an document like this in that , How can I group the array contents with the similar value and get the count of it ? Something like below . Can someone help me with this ?
{
"brands": [
{
  "value": "brand1",
  "count": 2
},
{
  "value": "brand2",
  "count":1
}
],
"count": 3,
"name": "Windows"
}