Does $sortByCount work in compass?

I tried to create a pipeline in compass using sortByCount but I’m not getting any results.
I also saw this jira : https://jira.mongodb.org/browse/COMPASS-3195

thanks

Let’s see your screenshots.

It was just a trial test on a local database under $sortByCount option

/
**

  • expression: Grouping expression or string.
    */
    {
    “$type”
    }

Exporting pipeline to language returns this
[{}]

A match exports returns this
[{
$match: {
“type”: “Refinement”
}
}]

This line works in mongoshell
db.recipes.aggregate([{$sortByCount: “$type”}])

It’s a bug! Remove the curly braces and have it looking like this:
image
The support ticket is very disappointing, especially for a bug that was reported in version 1.16 and we’re now in version 1.20. And all it says is “Won’t fix” without any comments from the staff who closed the ticket.
@Sonali_Mamgain may have some insight :slight_smile:

That worked, thank you :slight_smile:

You also have to remove any extra blank lines, the expression has to be right after the comments.

( Might be a problem in the token parsing yeah, or maybe the syntax analysis. )