Hiya
I’m trying to work out how to create a facet aggregation against a structure a bit like…
_id: 1234
titles: Array
0: "aaaa"
1: "bbbb"
2: "cccc"
skills: Object
ep: "ABC"
fn: "Fred"
fm: null
cs: "handed off"
counter: 2
seen: true
what I’d like is a count for each of the skills
I can get a count for each of the titles:
"$facet": {
"count": [
{
"$count": "count"
}
],
"titles": [
{
"$unwind": "$titles"
},
{
"$group": {
"_id": "$titles",
"count": {
"$sum": 1
}
}
},
{
"$sort": {
"_id": 1
}
}
],
How do I get the same for each of the elements in skills, please?
There are about 3 million records so creating an array of each of the skills and then doing the same as I’ve done for titles does not perform well (i.e. >60 seconds)