Tnx. That would read in a huge amount of data in Python that increases the wait time. I've done some speed tests and notice that mongo queries are really quick and so are the Python functions. Problem is the size of the data so I would like to limit my query result to a minimum.
It doesn't have to query huge amount of data if you filter out some of them first. In your example you may want to filter the collection with {$match: {a: {$in: ['x', 'y', 'z', ...]}}}
Thanks for all the answers: 1. Using the $match example I'm not concerned to query allot of data, I'm concerned of getting a very large response and reading that into Python. I like the query result to be as minimized as possible. I can't see how this example actually limits the response to 10 documents for each keyvalue of a? 2. During my mongo course :) I was warned to use map reduce and if I understand correctly the part where the data is limited has to happen in the python code? I might be completely wrong about this though - can't find any good example online?
{$match: {a: {$in: ['x', 'y', 'z', ...]}}}