Answer by prayagupd for How to query MongoDB with "like"?
Like Query would be as shown below db.movies.find({title: /.*Twelve Monkeys.*/}).sort({regularizedCorRelation : 1}).limit(10); for scala ReactiveMongo api, val query = BSONDocument("title" ->...
View ArticleAnswer by Vaibhav for How to query MongoDB with "like"?
If you are using Spring-Data Mongodb You can do this in this way: String tagName = "m"; Query query = new Query(); query.limit(10); query.addCriteria(Criteria.where("tagName").regex(tagName));
View ArticleAnswer by The6thSense for How to query MongoDB with "like"?
Already u got the answers but to match regex with case insensitivity You could use the following query db.users.find ({ "name" : /m/i } ).pretty() The i in the /m/i indicates case insensitivity and...
View ArticleAnswer by Dap for How to query MongoDB with "like"?
For PHP mongo Like. I had several issues with php mongo like. i found that concatenating the regex params helps in some situations PHP mongo find field starts with. I figured I would post on here to...
View ArticleAnswer by cmarrero01 for How to query MongoDB with "like"?
You can use the new feature of 2.6 mongodb: 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"});...
View ArticleAnswer by Johnathan Douglas for How to query MongoDB with "like"?
db.users.insert({name: 'paulo'}) db.users.insert({name: 'patric'}) db.users.insert({name: 'pedro'}) db.users.find({name: /a/}) //like '%a%' out: paulo, patric db.users.find({name: /^pa/}) //like 'pa%'...
View ArticleAnswer by MADHAIYAN M for How to query MongoDB with "like"?
In SQL, the ‘like’ query is looks like this : select * from users where name like '%m%' In MongoDB console, it looks like this : db.users.find({"name": /m/}) // Not JSON formatted...
View ArticleAnswer by user2312578 for How to query MongoDB with "like"?
In Go and the mgo driver: Collection.Find(bson.M{"name": bson.RegEx{"m", ""}}).All(&result) where result is the struct instance of the sought after type
View ArticleAnswer by Eddy for How to query MongoDB with "like"?
If using node.js, it says that you can write this: db.collection.find( { field: /acme.*corp/i } ); //or db.collection.find( { field: { $regex: 'acme.*corp', $options: 'i' } } ); Also, you can write...
View ArticleAnswer by brenoriba for How to query MongoDB with "like"?
You can use where statement to build any JS script: db.myCollection.find( { $where: "this.name.toLowerCase().indexOf('m') >= 0" } ); Reference: http://docs.mongodb.org/manual/reference/operator/where/
View ArticleAnswer by Afshin Mehrabani for How to query MongoDB with "like"?
In PyMongo using Python Mongoose using Node.js Jongo, using Java mgo, using Go you can do: db.users.find({'name': {'$regex': 'sometext'}})
View ArticleAnswer by leon for How to query MongoDB with "like"?
In PHP, you could use following code: $collection->find(array('name'=> array('$regex' => 'm'));
View ArticleAnswer by Kyle H for How to query MongoDB with "like"?
That would have to be: db.users.find({"name": /.*m.*/}) or, similar: db.users.find({"name": /m/}) You're looking for something that contains "m" somewhere (SQL's '%' operator is equivalent to Regexp's...
View ArticleAnswer by Joshua Partogi for How to query MongoDB with "like"?
You would use regex for that in mongo. e.g: db.users.find({"name": /^m/})
View ArticleHow to query MongoDB with "like"?
I want to query something with SQL's like query: SELECT * FROM users WHERE name LIKE '%m%' How to do I achieve the same in MongoDB? I can't find an operator for like in the documentation.
View ArticleAnswer by Lazaro Fernandes Lima Suleiman for How to query MongoDB with "like"?
If you have a string variable, you must convert it to a regex, so MongoDb will use a like statement on it. const name = req.query.title; //Johndb.users.find({ "name": new Regex(name) });Is the same...
View ArticleAnswer by KayV for How to query MongoDB with "like"?
Here is the command which uses starts with paradigmdb.customer.find({"customer_name" : { $regex : /^startswith/ }})
View ArticleAnswer by Ezequias Dinella for How to query MongoDB with "like"?
You can query with a regular expression:db.users.find({"name": /m/});If the string is coming from the user, maybe you want to escape the string before using it. This will prevent literal chars from the...
View ArticleAnswer by ajay_fuel_stock_lamp_stack for How to query MongoDB with "like"?
There are various ways to accomplish this.simplest-onedb.users.find({"name": /m/}){ <field>: { $regex: /pattern/, $options: '<options>' } }{ <field>: { $regex: 'pattern', $options:...
View ArticleAnswer by waseem khan for How to query MongoDB with "like"?
One way to find the result as with equivalent to like querydb.collection.find({name:{'$regex' : 'string', '$options' : 'i'}}) Where i use for cases insensitive fetch dataAnother way by which we can get...
View Article