Quantcast
Channel: How to query MongoDB with "like" - Stack Overflow
Browsing index pages (48 articles)
↧

Answer by Kerem Atasen for How to query MongoDB with "like"

It works too:db.getCollection('collection_name').find({"field_name": /^searched_value/})

View Article


Answer by Sahil Patel for How to query MongoDB with "like"

If you want to use mongo JPA like query you should try this.@Query("{ 'title' : { $regex: '^?0', $options: 'i' } }")List<TestDocument> findLikeTitle(String title);

View Article


Answer by Sahil Thummar for How to query MongoDB with "like"

In MongoDb, can use like using MongoDb reference operator regular expression(regex).For Same Ex.MySQL - SELECT * FROM users WHERE name LIKE '%m%'MongoDb 1) db.users.find({ "name": { "$regex": "m",...

View Article

Answer by Binita Bharati for How to query MongoDB with "like"?

Just in case, someone is looking for a sql LIKE kind of query for a key that holds an Array of Strings instead of a String, here it is:db.users.find({"name": {$in: [/.*m.*/]}})

View Article

Answer by Priyanka Wagh for How to query MongoDB with "like"?

Above answers are perfectly answering the questions about core mongodb query. But when using pattern based search query such as:{"keywords":{ "$regex": "^toron.*"}}or{"keywords":{ "$regex":...

View Article


Answer by turivishal for How to query MongoDB with "like"?

Using javascript RegExpsplit name string by space and make array of wordsmap to iterate loop and convert string to regex of each word of namelet name = "My Name".split("").map(n => new...

View Article

Answer by Shubham Kakkar for How to query MongoDB with "like"?

{ $text: { $search: filter } }, ); if (indexSearch.length) { return indexSearch; } return UserModel.find( { $or: [ { firstName: { $regex: `^${filter}`, $options: 'i' } }, { lastName: { $regex:...

View Article

Answer by g10guang for How to query MongoDB with "like"?

Skip this answer, if you don't use go driver.filter := bson.M{"field_name": primitive.Regex{ Pattern: keyword, Options: "", },}cursor, err := GetCollection().Find(ctx, filter)Use regex in $in query,...

View Article


Answer 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


Answer 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 Article

Answer 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 Article

Answer 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 Article

Answer 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 Article


How 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 Article

Answer 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 Article


Answer 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 Article

Answer by leon for How to query MongoDB with "like"?

In PHP, you could use following code: $collection->find(array('name'=> array('$regex' => 'm'));

View Article


Answer 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 Article

Answer 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 Article

Answer 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 Article
Browsing index pages (48 articles)


Latest Images