mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Support other kwargs for Map Reduce

Open rozza opened this issue 14 years ago • 1 comments

MongoDB Map Reduce allows for a sort parameter as seen here: http://www.mongodb.org/display/DOCS/MapReduce#MapReduce-NoteonPermanentCollections "... [, sort : <sorts the input objects using this key. Useful for optimization, like sorting by the emit key for fewer reduces>] ... "

I see pymongo's map_reduce function accepts this arg through **kwargs. I cannot see a way to do this using mongoengine. Do I need to override the mongoengine map_reduce method or is there a way to do it that I am missing?

I tried using order_by on the QuerySet before calling the map/reduce but this does not appear to have the desired affect as it does not appear to be ordering the results before handing them off to the map/ reduce

rozza avatar Oct 27 '11 07:10 rozza

Rather than adding arguments to map_reduce we should use the args as they are on the QuerySet being map-reduced. This already happens for the query, but we should also support limit and sort.

dcrosta avatar Oct 27 '11 22:10 dcrosta