I wanted to find sub-strings within a field in MongoDB using PyMongo.
The following query works fine and is what I require:
db.collection.find({ "Animal": /cat|Dog/i})
However, if I try passing the value /cat|Dog/i
as a string in Python, it doesn't work.
Is there a way to replicate the query in PyMongo?
Note: /cat|Dog/i
is value of field from another collection. It is in the form 'cat Dog'. Basically, I want to match substrings in one field with substrings in another.