Is it true that Map/Reduce results can be stored permanently, but not sorted? For example,
coll = Analytic.collection.map_reduce(map, reduce,
:out => 'analyticsCachedResult')
the above is stored permanently but is not sorted.
To sort it on the fly, it can be
coll.find({}, :sort => ['value.pageviews', :desc])
But can you sort the table internally? I think if an index is created for the sort key, then it will be almost as good as sorting it internally?
Or, how can we sort it, and save it as a new collection analyticsSortedCachedResult
?
I think later on, to get any collection using Mongoid, it is by
coll = Mongoid.master.collection('analyticsCachedResult')
? but I am just worried that since Mongoid.master.collection('foo')
will still return a collection even if the collection doesn't exist. But looks like it is not saved into MongoDB either.