As far as I know, I can’t specify a complex sort function in Mongo so I have to use a map/reduce query which feels a bit useless since I don’t even use the reduce portion. This is fine but the collection it returns is too large, I need to sort and limit it (paginate). Is it possible to do that with an inline call? I can’t store the resulting collection and then query it because the collection is unique to each user and constantly changing.
Share
Normally
sortin mongodb mapreduce applied before the map, literally they are applied to the input data not the output.From mongodb docs
So if you want to sort & limit the map reduce output, you must store the result in temp collection. I dont think its possible to apply the sort & limit to the
inlinemapreduce output since it runs on RAM.EDIT:
There is a open issue (Add support for sorting and limiting inline map/reduce) in mongodb Jira regarding this. Have a look.