incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hank Knight <>
Subject CouchDB: Group results by unique values
Date Fri, 26 Jul 2013 20:28:51 GMT
I have 1000 of rows but the containing data about fruit.  There are
only 10 unique values for the field "fruit".

I would like to count the total number of occurrences for each unique
"fruit" value.

This returns 1000 results:

function(doc) {
  if (doc.fruit) emit(doc.fruit,doc.fruit.length);

How can I limit the results so each unique value for fruit is only
returned once?
In MySQL I would use something like:
SELECT `fruit`, COUNT(`fruit`) GROUP BY `fruit`


View raw message