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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer by Kerem Atasen for How to query MongoDB with "like"
It works too:db.getCollection('collection_name').find({"field_name": /^searched_value/})
View Article