Assume a collection with documents which look like this:
{
"username" : "Aventinus"
"text": "I love StackOverflow!",
"tags": [
"programming",
"mongodb"
]
}
Using text index and the following command in MongoDB I can find all documents whose text contains the word StackOverflow
and store them in another collection:
db.C_a.aggregate([
{$match: {$text: {$search:"StackOverflow"}}},
{$out:"C_b"}
]);
However, I would like to run the above snippet for a list of keywords (more than 200) so I need to automate this process by writing a Python script.
Question: What is the equivalent of the above snippet in PyMongo?