Mongoose.js Search With Full Text Search

If you’ve tried to use Regular Expressions to search for a string of text in Mongo, you’ve probably noticed that it is really slow.

Use “full text search” instead! The end result will be similar to using a  “LIKE” query in SQL.

NOTE: In order to use this feature, you must create a text index on a field in your data.

How to Make Text Search Really Fast in MongoDB

var name = 'Peter';
model.find({ $text: { $search: name } }, function(err, doc) {
  //Do your action here..
});

How to Use Full Text Search with Exec

model.find({ $text: { $search: q } })
 .limit(20)
 .exec(function (err, items) {
    console.log("items", items);
});

Sources: MongoDB & Comsysto