У меня есть коллекция с такими документами:
{ "_id" : ObjectId("5b91035eca4f00000124e1d8"), "status" : 0, "date" : NumberLong(0), "players" : [ { "name" : "Valentin", "sets" : [ { "points" : [ { "score" : 0, "comment" : "" }, { "score" : 0, "comment" : "" }, { "score" : 0, "comment" : "" }, { "score" : 1, "comment" : "sa" }, { "score" : 1, "comment" : "" }, { "score" : 1, "comment" : "" }, { "score" : 1, "comment" : "" }, { "score" : 1, "comment" : "" }, { "score" : 1, "comment" : "" }, { "score" : 1, "comment" : "" }, { "score" : 2, "comment" : "" }, { "score" : 2, "comment" : "" }, { "score" : 2, "comment" : "" }, { "score" : 2, "comment" : "" }, { "score" : 3,"comment" : "sw" }, { "score" : 3, "comment" : "" }, { "score" : 3, "comment" : "" }, { "score" : 4, "comment" : "sa" }, { "score" : 5, "comment" : "bh" }, { "score" : 5, "comment" : "" }, { "score" : 5, "comment" : "" }, { "score" : 6, "comment" : "fh" }, { "score" : 6, "comment" : "" }, { "score" : 7, "comment" : "sw" }, { "score" : 7, "comment" : "" }, { "score" : 7, "comment" : "" }, { "score" : 8, "comment" : "" }, { "score" : 8, "comment" : "" }, { "score" : 9, "comment" : "bh" }, { "score" : 10, "comment" : "sw" }, { "score" : 11, "comment" : "sw" } ] } ] }, { "name" : "Zalupkin", "sets" : [ { "points" : [ { "score" : 0, "comment" : "" }, { "score" : 1, "comment" : "" }, { "score" : 2, "comment" : "" }, { "score" : 2, "comment" : "" }, { "score" : 3, "comment" : "fh"}, { "score" : 4, "comment" : "sw" }, { "score" : 5, "comment" : "" }, { "score" : 6, "comment" : "" }, { "score" : 7, "comment" : "" }, { "score" : 8, "comment" : "sa" }, { "score" : 8, "comment" : "" }, { "score" : 9, "comment" : "fh" }, { "score" : 10, "comment" : "sa" }, { "score" : 11, "comment" : "bh" }, {"score" : 11, "comment" : "" }, { "score" : 12, "comment" : "" }, { "score" : 13, "comment" : "" }, { "score" : 13, "comment" : "" }, { "score" : 13, "comment" : "" }, { "score" : 14, "comment" : "" }, { "score" : 15, "comment" : "sa" }, { "score" : 15, "comment" : "" }, { "score" : 16, "comment" : "sw" }, { "score" : 16, "comment" : "" }, { "score" : 17, "comment" : "" }, { "score" : 18, "comment" : "" }, { "score" : 18, "comment" : "" }, { "score" : 19, "comment" : "sa" }, { "score" : 19, "comment" : "" }, { "score" : 19, "comment" : "" }, { "score" : 19, "comment" : "" } ] } ] } ] }
Я попытался создать конвейер агрегации, чтобы посчитать, как в гривенном комментарии "sw" есть игрок с именем "Valentin".
Также этоможет быть во многих документах, и мне нужно сосчитать целые комментарии.
Результат должен выглядеть примерно так: {"_id": null, "count": 0}
Спасибо за помощь.