I was successful in running $text search using Mongoose in Node.js code. Here is the code I used:
Model.find(
{ $text : { $search : "FindThisString"}},
{ score : {$meta : "textScore"}}
)
.sort({ score : { $meta : 'textScore'}})
.exec(function(err, results) {
_.each(results, function(item) {
//console.log(item);
console.log(item._id);
console.log(item.score);
});
});
When I console log the entire document, I can see the "score" field in on the console, but "item.score" prints as "undefined".
How can I access the score created by MongoDB in the returned results?