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.
>