I have created index now want to do a full text search along with a where condition, Suppose i want to search a term and check if the expireDate
is not expired, so it should search the search term only inside those documents that are not expired. What I have tried is:
JobPosting
.find(
{ $text : { $search : searchTerm } },
{ score : { $meta: "textScore" } }
)
.sort({ score : { $meta : 'textScore' } })
.exec(function(err, results) {
console.log(results)
// callback
});
But above code has problem, sort()
and exec()
is not a function, and the second problem is with where condition. How i can check expireDate
? If i remove sort()
and exec()
bring the wrong result (bring all result).
via jones
No comments:
Post a Comment