Quantcast
Channel: How to query MongoDB with "like" - Stack Overflow
Browsing all 48 articles
Browse latest View live

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 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 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 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 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 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 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 Kerem Atasen for How to query MongoDB with "like"

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

View Article

Browsing all 48 articles
Browse latest View live