Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 21114 invoked from network); 15 Oct 2010 12:34:34 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 15 Oct 2010 12:34:34 -0000 Received: (qmail 22079 invoked by uid 500); 15 Oct 2010 12:34:33 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 21730 invoked by uid 500); 15 Oct 2010 12:34:30 -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 21721 invoked by uid 99); 15 Oct 2010 12:34:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Oct 2010 12:34:29 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of wout.mertens@gmail.com designates 209.85.215.52 as permitted sender) Received: from [209.85.215.52] (HELO mail-ew0-f52.google.com) (209.85.215.52) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Oct 2010 12:34:20 +0000 Received: by ewy23 with SMTP id 23so424391ewy.11 for ; Fri, 15 Oct 2010 05:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=mFKtuHcGA041x9hcC5v6Cg5zyPTabVJB+vsRv92jygU=; b=YedO4gh2Not1g/EUldyHPVeEn5PfEfRfR3vQFBF/5X5YrcS/P7dS0EJwTqk5jEX8ru p+R8Fre/GDIwawGLvf7gPk8vUQDd+VJ63s+7nbTQerMkIJNHDu8bomW6J1Gv3U6QnrbI R/TE8s7oJZPLUEZR8S4u0Ur87lfncV6o0rNms= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=FJXYgRmNKXSLuyxhIzteP0ubNe0888SGPRcyKHJW82DRYmwJrUFIb/lozL2fd2G/Mo /T54BIsC8uhQj5MNETumCH2mtekzdGYQGJ4fEYg2pCMGIFoyEHhU2fe/YSPupHNz02YH +5Mg+skFKwiMhesxX3OrcT0NOEa3KK/iV3ohU= Received: by 10.213.34.79 with SMTP id k15mr656050ebd.26.1287146037978; Fri, 15 Oct 2010 05:33:57 -0700 (PDT) Received: from [192.168.1.20] ([83.101.90.105]) by mx.google.com with ESMTPS id z55sm18199270eeh.21.2010.10.15.05.33.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 15 Oct 2010 05:33:56 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1081) Subject: Re: how to count the number of unique values From: Wout Mertens In-Reply-To: Date: Fri, 15 Oct 2010 14:33:53 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <9FE98F86-B81E-4B5D-AEE9-07FF33ED201D@gmail.com> References: To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1081) X-Virus-Checked: Checked by ClamAV on apache.org Just wanted to add that if you have a map function that emits (tag, 1) = for each tag and then a reduce function that's just _count, you will = have everything you need for painting a tag cloud. The view with group=3Dtrue will list all tags exactly once, with their = count. CouchDB doesn't tell you how many rows are in the result so = you'll have to count them yourself. So you load that entire view in memory and you can draw the tags with = their relative sizes. Wout. On Oct 12, 2010, at 15:09 , Anand Chitipothu wrote: > Is it possible to count the number of unique values by writing a = couchdb view? >=20 > A typical example is to find the number of tags in a blog application. >=20 > Consider the following 2 docs. >=20 > { > "_id": "posts/1", > "title": "post 1", > "tags": ["foo", "bar"] > } >=20 > { > "_id": "posts/2", > "title": "post 2", > "tags": ["foo", "foobar"] > } >=20 > Is it possible to find that there are 3 tags? >=20 > Anand