incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Metin Akat <akat.me...@gmail.com>
Subject Re: ranking a big list
Date Sat, 06 Feb 2010 17:03:21 GMT
with this map/reduce setup, the way to get the number of students
above some value is to query with endkey=<<the score>> and
descending=true

On Sat, Feb 6, 2010 at 6:53 PM, Mano <manokaran@gmail.com> wrote:
> On Sat, Feb 6, 2010 at 9:17 PM, Mano <manokaran@gmail.com> wrote:
>
>>
>> On Sat, Feb 6, 2010 at 6:57 PM, Metin Akat <akat.metin@gmail.com> wrote:
>>
>>> Hi,
>>> What if 2 students have score of 200 and the next 3 have score of 199?
>>> How do you decide who is fourth?
>>>
>>>
>> There is no fourth rank in that case. Only first (the 2 200's) third (the 3
>> 199's) and sixth etc ranks.
>>
>
> To elaborate, the rank here is to help infer how many students have scored
> better than a given score. Thought of the following scheme. Any pitfalls in
> this?
>
> map: function(doc){
>    emit(doc.score, 1);
> }
> reduce: function(keys, values){
>    return sum(values);
> }
>
> So, to get the rank of, say, 186, I'll query the view with the key: 187 in
> descending order. Will update after I try this out.
>
> thanks,
> mano
>

Mime
View raw message