couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hank Knight <hknight...@gmail.com>
Subject Re: CouchDB: Counting Total Occurrences of Unique Items
Date Sun, 28 Jul 2013 23:00:32 GMT
Thank you for your patience with me.  That works!

On Sun, Jul 28, 2013 at 6:56 PM, Stanley Iriele
<siriele@breaktimestudios.com> wrote:
> The problem here is that you seem to not understand how the emit and key
> value map reduce works.
>
> Emit (key,value) couch db sorts and groups based off key.
>
> In short your emit should be: emit( doc.fruit, null) if that's all you care
> about... And your reduce function should be _count
>
> The group param is for grouping the keys.
>
> You can use group_level if there was an array of keys but this should
> answer your question
> On Jul 28, 2013 5:45 PM, "Hank Knight" <hknight555@gmail.com> wrote:
>
>> My map function is here:
>> function (doc) {
>>  if (doc.fruit) emit("fruit",doc.fruit);
>> }
>>
>> My reduce function is here:
>> function (keys, values, rereduce){
>>    var r  = {};
>>    for (var f=0;f<values.length;f++)
>> r[values[f]]?r[values[f]]++:r[values[f]]=1;
>>    return r ;
>> }
>>
>> View it here::
>>
>> https://zurv3aqzm.iriscouch.com/_utils/database.html?fruit/_design/zzz3/_view/zzz3#
>>
>> I do not understand how to group the results.
>>

Mime
View raw message