I have articles which are sorted by their rating using .sort( { rating : -1 } )
I have a lot of articles which do not have any rating (In the DB side, they haven’t even the rating key). In the front end, I show them with a rate of 0.5 of 1.
When I sort the articles, I have now this order :
1 1 0.89 0.7 0.5 0.2 0.1 0 0 0 0 0 no_key no_key no_key no_key no_key no_key...
But, I would like to take in account that no_key is more a 0.5 rating than a zero (even lower in the previous sorting). So, I would like something like this :
1 1 0.89 0.7 0.5 no_key no_key no_key no_key no_key no_key... 0.2 0.1 0 0 0 0 0
I want to avoid to have to fill the missing rating keys of the unrated articles by 0.5.
Any tricks ? Any Ideas ?
So, this requires three separate queries, but until the Aggregation framework ( http://www.mongodb.org/display/DOCS/Aggregation+Framework ) comes out, it’s probably the best way: