$in中的正则表达式查询不起作用。它在mongo shell中运行良好。
不起作用:
OpMatch := bson.M{"$match": bson.M{"wordname": bson.M{"$in": [...]string{"/^how$/"}}}}作品:
OpMatch := bson.M{"$match": bson.M{"wordname": bson.M{"$in": [...]string{"how"}}}}发布于 2016-09-06 21:30:09
这不是使用mgo进行正则表达式的方式。您必须使用bson.RegEx。试试这个:
bson.M{"$match": bson.M{"wordname": bson.M{"$in": []bson.RegEx{{"^how$", "i"}}}}}
https://stackoverflow.com/questions/39349612
复制相似问题