fix: add support for descending sorting of full text search (#7496)

This commit is contained in:
dblythy
2021-09-16 00:15:08 +10:00
committed by GitHub
parent e9e3be1df8
commit 8ed94421e6
3 changed files with 140 additions and 390 deletions

View File

@@ -143,7 +143,7 @@ function RestQuery(
var fields = restOptions.order.split(',');
this.findOptions.sort = fields.reduce((sortMap, field) => {
field = field.trim();
if (field === '$score') {
if (field === '$score' || field === '-$score') {
sortMap.score = { $meta: 'textScore' };
} else if (field[0] == '-') {
sortMap[field.slice(1)] = -1;