Is it possible to sort text-search results using a projection that combines {$meta: "textScore"} with some other values? Each of our documents has a quality (pagerank) score, and I would like to sort results using the product of the text-match and the pagerank for the document:
var cursor = packages.find(query).project({
score: {$multiply: [{$meta: "textScore"}, '$_pagerank']},
Foo: 1,
Bar:1,
}).sort({score:-1}).limit(limit);
The results for the above query do contain the expected score values, but the output is not sorted at all. I tested that sorting does work based on only the textScore .sort({score:{$meta:"textScore"}}) however that does not take the pagerank of the document into account.
Is it possible at all to sort in mongodb using a projected value? We are currently using mongodb 4.4.