MongoDB:按TextScore和其他价值的产品排序
是否可以使用将{$ META:“ textscore”}
与其他一些值结合的投影对文本搜索结果进行排序?我们的每个文档都有质量(Pagerank)分数,我想使用文本匹配和Pagerank的产品对文档进行分类:
var cursor = packages.find(query).project({
score: {$multiply: [{$meta: "textScore"}, '$_pagerank']},
Foo: 1,
Bar:1,
}).sort({score:-1}).limit(limit);
上述查询的结果确实包含了预期的分数值,但根本不排序输出。我测试了排序仅基于textScore
,但这并不考虑文档的pagerank。.sort({score:{$ meta:“ text -score”}})
是否有可能使用投影值在MongoDB中进行排序?我们目前正在使用MongoDB 4.4。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论