I have full text search returning results from a Keystone model. The problem is that I am generating these results using model.find()
. I want to paginate these results, but I can't find a way to use $text
with .paginate()
. Is there a way to integrate mongoose full text search with Keystone pagination, or even paginate results from model.find()
?
EDIT
I have tired using keystone.list('List').paginate().find()
but I receive an error: "callback is not a function." Perhaps there is something else wrong with my code:
keystone.list('Document').paginate({
page: req.query.page || 1,
perPage: 10,
maxPages: 6,
})
.find(
{ $text : { $search : req.query.search } },
{ score : { $meta: "textScore" } }
)
.sort({ score : { $meta : 'textScore' } })
.exec(function(err, results) {
locals.documents = results;
next();
});
model
. I have also tried paginate().model.find(), which does the same thing as if I simply called model.find(). - ttyelud