I have a huge collection of tweets downloaded by someone else and I want to test an aggregate() query on that. But, it takes a lot of time to execute and I want to quickly check my results.
Can I create a smaller sample collection using the huge original collection so that I can test new queries on that quickly? If yes, how can I do that? If no, how do people usually test the correctness of the query before execution?
All the answers I found till now say about dumping the entire collection while I just want a sample of it to run my aggregate() query. I've tried doing a db.collection.findOne().aggregate(/*QUERY*/) but it throws an error saying that aggregate is not a function
you can easily create a subset of your collection like this :
db.collection.aggregate({$limit: 1000}, {$out: "subsetCollection"})
this will take 1000 results from yout original collection and write the to a new collection named "subsetCollection". You can then test your aggregation queries on this new collection