Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8B7FCCE1B for ; Fri, 26 Jul 2013 22:09:39 +0000 (UTC) Received: (qmail 57802 invoked by uid 500); 26 Jul 2013 22:09:38 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 57766 invoked by uid 500); 26 Jul 2013 22:09:38 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 57758 invoked by uid 99); 26 Jul 2013 22:09:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jul 2013 22:09:37 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [209.85.214.175] (HELO mail-ob0-f175.google.com) (209.85.214.175) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jul 2013 22:09:32 +0000 Received: by mail-ob0-f175.google.com with SMTP id xn12so5468346obc.34 for ; Fri, 26 Jul 2013 15:08:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=oJXkpGstaaOsoleXm2jzlp5pBPKOsgvnl1R9dbBtjnA=; b=Q+2xhy+AbrRK6LdtLvWoNGXtuvkKtX+K2Lhg+CSfJsy93JSK8/X4ghDMXOqiCgzHIG BwYHTKTeFWW2Bvm4ZCpn+h52IU/mRiI0dK7W4lMlpCABjft3WW9fsDsdUoKKhsn3Vxo5 hKs3wXep/gi+05gs5XrYtIf/DXx5DnnHbg5PWGa2dZeH/AvVDBdIls4nxRAEoGqJAuef dBJ0uuwZfqR/XRtDQL7rW+foyWH7IQSuLH+l+R0tnCL7R4VfbIIYz10pH+RBz8SU013f FBKoC41vFT6pvQgf6v+mDr9b/A7PmCPhC0i/VKj6BqAf5pEH4sx1CGpQNHepbCIb50UX vasw== MIME-Version: 1.0 X-Received: by 10.60.77.70 with SMTP id q6mr49902450oew.98.1374876530965; Fri, 26 Jul 2013 15:08:50 -0700 (PDT) Received: by 10.182.246.33 with HTTP; Fri, 26 Jul 2013 15:08:50 -0700 (PDT) Received: by 10.182.246.33 with HTTP; Fri, 26 Jul 2013 15:08:50 -0700 (PDT) In-Reply-To: References: Date: Fri, 26 Jul 2013 15:08:50 -0700 Message-ID: Subject: Re: CouchDB: Group results by unique values From: Stanley Iriele To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=047d7b33d3e03d123704e2716353 X-Gm-Message-State: ALoCoQk7DDY+1Ya+Kad7I1OAK9KI+YWDjFdLcslSZ8HPGGiu539meWW16S9xkolre4aTc0o5foBw X-Virus-Checked: Checked by ClamAV on apache.org --047d7b33d3e03d123704e2716353 Content-Type: text/plain; charset=ISO-8859-1 I'm not sure what you ate trying to accomplish...that link just says not found. Try getting Erica installed... That will help you out a lot. When you make your map/reduce function in the reduce section..instead of a function... Just put _count. And couchdb will recognize that as a call to a built in function. Regards, Stanley On Jul 26, 2013 4:51 PM, "Hank Knight" wrote: > I don't care about the string length. I thought that fruit.length > would count the instances of that fruit however at a closer glance it > only tells me how many characters are in the string! > > Specifically, how can I use function _count? > > Please look here: > > https://zurv3aqzm.iriscouch.com/_utils/database.html?fruit/_all_docs > https://zurv3aqzm.iriscouch.com/_utils/database.html?fruit/_temp_view > > Thanks. > > On Fri, Jul 26, 2013 at 5:41 PM, Stanley Iriele > wrote: > > Also you can use arrays as keys as well in group by that.. So [fruit, > > weight, etc,] and value can be whatever you want...then use the couchdb > > built in reduce function _count > > On Jul 26, 2013 4:34 PM, "Stanley Iriele" wrote: > > > >> Is fruit a string or an array here?.. Why do you care about the fruit > >> length? > >> On Jul 26, 2013 4:29 PM, "Hank Knight" wrote: > >> > >> > 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` > >> > > >> > --- > >> > Thanks! > >> > > >> > --047d7b33d3e03d123704e2716353--