This is my structure:
document 1 has
{
"people": [
{
"name": "Darrell",
"age": "10",
},
{
"name": "Karen",
"age": "20",
},
{
"name": "Gary",
"age": "30",
}
]
}
Document 2 has
{
"people": [
{
"name": "Karen",
"age": "25",
},
{
"name": "Gary",
"age": "30",
}
]
}
Now, how can I perform count aggregation on individual array elements that matched the query?
- If I query for name:Karen, I need the count as 2.
- If I query for name:Karen && age:20, I need the count as 1.
- If I query for name:Gary && age:30, I need the count as 2.