Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 70654 invoked from network); 9 Nov 2008 22:02:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Nov 2008 22:02:21 -0000 Received: (qmail 29699 invoked by uid 500); 9 Nov 2008 22:02:27 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 29665 invoked by uid 500); 9 Nov 2008 22:02:27 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 29654 invoked by uid 99); 9 Nov 2008 22:02:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Nov 2008 14:02:27 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jchris@gmail.com designates 74.125.46.153 as permitted sender) Received: from [74.125.46.153] (HELO yw-out-1718.google.com) (74.125.46.153) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Nov 2008 22:01:07 +0000 Received: by yw-out-1718.google.com with SMTP id 5so828891ywr.0 for ; Sun, 09 Nov 2008 14:01:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=Rvho50nIna3IUg7X9An5niMMSnEERExk6I4ATeWCWAg=; b=cVqjTV13NyU1lBwjk35JleFcSxNQrrKl/0bSm4XidaRVZkDSRplMC4ZsoY2ylrBgsD wixPYue8wmcQnUHmsBjkgY41j3kaTmXoIQ/Y0gXLxp0WteXgk6s1YUBHuS1Wx2t5Ne31 SNGNQ2rYMO5MKdVCI8Ex6PBM8aOXooWFGQgIM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=Bzct9rrp4FD4oIUHKd56LektzAV/DjUuyFyR+v/WdyBCutnqH9ThUZhFc5ZdpM3hEE MCxZgcJiOEaDZhAV5Fb/2fZLH4/tGZwCnVKmv52VslMVoVmcRlNDqZohtmcwuFohvo+w 1N6sGVJeSaP3Qkf+3u5LKJjg1K3H/1LdULSrQ= Received: by 10.64.151.10 with SMTP id y10mr6212484qbd.95.1226268109237; Sun, 09 Nov 2008 14:01:49 -0800 (PST) Received: by 10.64.241.20 with HTTP; Sun, 9 Nov 2008 14:01:48 -0800 (PST) Message-ID: Date: Sun, 9 Nov 2008 14:01:48 -0800 From: "Chris Anderson" Sender: jchris@gmail.com To: couchdb-user@incubator.apache.org Subject: Re: dual purpose filter/count views In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Google-Sender-Auth: 25f8079301bff3b7 X-Virus-Checked: Checked by ClamAV on apache.org On Sun, Nov 9, 2008 at 1:36 PM, Sho Fukamachi wrote: > map: function(doc) { > if (doc.type == 'my_doc') emit(doc.field, [doc, 1]); > } > reduce: function(keys, values) { return sum(values[1]) } Anthony's second email has a working idea, but this is how I like to do it. Will work for any map function, so you can drop the funny array value from your map. Reduce: function(keys, values, rereduce) { if (rereduce) { return sum(values); } else { return values.length; } } -- Chris Anderson http://jchris.mfdz.com