1

I would like to pass in a list to regex, as follows. I cannot find an evidence to see how to cojoin $in and $regex

query = {"platform": {"$regex": {"$in": [platform_list]}, "$options":"i"}, "$or": []}
result = mongo.db.xxx.find(query)

I get the error:

pymongo.errors.OperationFailure: database error: Can't canonicalize query: BadValue $regex has to be a string

How should I format the string, so that I can apply my query to each item in platform_list

disruptive
  • 5,687
  • 15
  • 71
  • 135

0 Answers0