mongoose-paginate-v2 icon indicating copy to clipboard operation
mongoose-paginate-v2 copied to clipboard

Cannot carry out a weighted text search

Open keniiy opened this issue 2 years ago • 1 comments

I am trying to apply the following query to the paginate function, but don't think it works.

var docItems = require('../models/docItems.js'); docItems.find( {$text: {$search: req.query.searchString}} , {score: {$meta: "textScore"}} ) .sort({ score : { $meta : 'textScore' } }) .exec(function(err, results) {

        return next(err, results);
    });

the , {score: {$meta: "textScore"}} line is what is missing in the following code:

docItems.paginate( {$text: {$search: req.query.searchString}, score: {$meta: "textScore"}}, { page: 1, sortBy: { score : { $meta : 'textScore' } }}, function(err, results, pageCount, itemCount) { console.log('hello'); return next(err, results, pageCount, itemCount); });

Is there a way to submit the score meta line? what am i missing?

keniiy avatar Apr 28 '22 10:04 keniiy

@keniiy Haven't tried that. Let me see if this can be fixed.

aravindnc avatar Jun 08 '22 19:06 aravindnc