Reputation: 11
The regular expression query in $in is not working. It works fine in the mongo shell.
Does not work:
OpMatch := bson.M{"$match": bson.M{"wordname": bson.M{"$in": [...]string{"/^how$/"}}}}
Works:
OpMatch := bson.M{"$match": bson.M{"wordname": bson.M{"$in": [...]string{"how"}}}}
Upvotes: 0
Views: 279
Reputation: 16440
That's not how you do regex with mgo. You must use bson.RegEx
. Try this:
bson.M{"$match": bson.M{"wordname": bson.M{"$in": []bson.RegEx{{"^how$", "i"}}}}}
Upvotes: 1