I am wondering why in Python with pymongo I cannot easily duplicate a collection by using aggregation operations such as $out
. In MongoDB the command work just fine. Instead, in Python the result is just an empty collection. Here the command I performed.
client = pymongo.MongoClient("mongodb://localhost:27017/")
db = client["my_database_name"]
col = db['my_collection_name']
pipeline = [ { "$match": { } } , { "$out": "my_collection_duplicate" } ]
result = db.col.aggregate(pipeline)
Alternatively, I followed the suggestion presented in this thread and it works, although the operation is far much slower. I am performing some recursive operations over the same collection, then I have to re-generate each time it in its 'original' form. I hope someone can enlighten me where I am wrong.