db.foo.insert({desc: "This is a string with text"});db.foo.insert({desc:"This is a another string with Text"});db.foo.ensureIndex({"desc":"text"});db.foo.find({$text:{$search:"text"}});
var collections = mongoDatabase.GetCollection("Abcd");
var queryA = Query.And(Query.Matches("strName", new BsonRegularExpression("ABCD", "i")),Query.Matches("strVal", new BsonRegularExpression("4121", "i")));
var queryB = Query.Or(Query.Matches("strName", new BsonRegularExpression("ABCD","i")),Query.Matches("strVal", new BsonRegularExpression("33156", "i")));
var getA = collections.Find(queryA);var getB = collections.Find(queryB);
db.users.find({$and: [{$and: [{ name: { $regex: "My" } },{ name: { $regex: "Name" } }]}// if you have multiple fields for search then repeat same block]})
MySQL - SELECT * FROM users WHERE name LIKE '%m%'
MongoDb
1) db.users.find({ "name": { "$regex": "m", "$options": "i" } })
2) db.users.find({ "name": { $regex: new RegExp("m", 'i') } })
3) db.users.find({ "name": { $regex:/m/i } })
4) db.users.find({ "name": /mail/ })
5) db.users.find({ "name": /.*m.*/ })
MySQL - SELECT * FROM users WHERE name LIKE 'm%'
MongoDb Any of Above with /^String/
6) db.users.find({ "name": /^m/ })
MySQL - SELECT * FROM users WHERE name LIKE '%m'
MongoDb Any of Above with /String$/
7) db.users.find({ "name": /m$/ })