Last active
June 10, 2023 07:52
-
-
Save dzhuryn/52b0c44e3789c52b31f92358661336f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.threads.aggregate([ | |
{ | |
"$match": { | |
"$text": { | |
"$search": "modx" | |
} | |
} | |
}, | |
{ | |
"$facet":{ | |
"count": [ | |
{ | |
"$group": {_id: null, count: {$sum: 1}} | |
} | |
], | |
"channelIDs": [ | |
{ | |
"$group": {_id: "$ci"} | |
} | |
] | |
} | |
} | |
]) | |
Result is: | |
{ | |
"count" : [ | |
{ | |
"_id" : null, | |
"count" : 360.0 | |
} | |
], | |
"channelIDs" : [ | |
{ | |
"_id" : ObjectId("60fdb9d0535ed8596df08b90") | |
} | |
] | |
} | |
Can i have result in form | |
{ | |
"count" : 360.0, | |
"channelIDs" : [ | |
ObjectId("60fdb9d0535ed8596df08b90" | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment