I need to run an aggregation query for a large collection which has 200,000+ data records. And I want to run it with pymongo. I tried out the preferred method in the docs.

pipeline = [...]
db.command('aggregate', 'statCollection', pipeline=pipeline_aggregate)

But this returned an error saying pymongo.errors.OperationFailure: The 'cursor' option is required, except for aggregate with the explain argument.
I solved the problem using allowDiskUse option. So this is my answer.

pipeline_2 = [...]
db.command('aggregate', 'statCollection', pipeline=pipeline_2, allowDiskUse=True, cursor={})
How to run pymongo aggregation query for large(200,000+ records) collection?