Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 26205 invoked from network); 29 Apr 2009 17:43:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Apr 2009 17:43:38 -0000 Received: (qmail 31306 invoked by uid 500); 29 Apr 2009 17:43:38 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 31247 invoked by uid 500); 29 Apr 2009 17:43:37 -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 31237 invoked by uid 99); 29 Apr 2009 17:43:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2009 17:43:37 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of luke.randall@gmail.com designates 209.85.219.166 as permitted sender) Received: from [209.85.219.166] (HELO mail-ew0-f166.google.com) (209.85.219.166) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2009 17:43:29 +0000 Received: by ewy10 with SMTP id 10so1550039ewy.11 for ; Wed, 29 Apr 2009 10:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=0AdhHDWD3vWSQ6l+txGog8gO62rU9qI2LLfsfYAt2Ww=; b=ASW8njQIWBxuOUKFZ6SEyhe685b8IzPUuu51nPxWpAqOrcvOotzGAzPfLmgFUBaifY DRf+v+oyIW1JdLgHcCUxIUgg+FhgQwRYP1p4LY9mkmMG38Dqy+biXh+qJm87eLj31i/x eyMz+r1QDsqcTl2zjueGZiVDBKQEFmUyhOuM8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=pV+gsgwCcVb7ZItMep+OlYyvMXdOtiPH/i8p9jeCHD6XtIVwEtu7qPdLkRBGgEfHlk 4E74MHTMGpO0gFhUgmoWd9S6PTQBxD5cI2l28EdsNEyG2AZkBYV/UlWPb5DpPggWCicl qcKEGUBC+8sRASFdcCqaYUE+0NtJ/FT9fXnuY= MIME-Version: 1.0 Received: by 10.210.119.5 with SMTP id r5mr700351ebc.30.1241026989655; Wed, 29 Apr 2009 10:43:09 -0700 (PDT) Date: Wed, 29 Apr 2009 19:43:09 +0200 Message-ID: <2c8465c20904291043r3f1f9402je8614e6db263ff04@mail.gmail.com> Subject: Re: Howto drop rows with reduce? From: Luke Randall To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Jurg van Vliet wrote: > if i don't emit anything in the last emit statement i get comments for all of my document types. then case i end up with a list of articles and comments, both with a comment count. > Hi Jurg >From what I understand of your situation, I don't see why what Paul suggested wouldn't work. If you have the following as your map function function(doc) { if( doc.type == 'Article') { emit( doc._id, 0); } else if( doc.type == 'Comment') { emit( doc.path[0], 1); } } when you reduce it* you will have a list of articles with a comment count. Note that you there is no requirement to call emit for each document. If you don't want a document to appear in a view then just don't call emit on it. Reduce isn't meant to be used as a filter, that's what map is for. * Remember to add :group => true to your couchrest view call, as Futon silently adds it, but it otherwise defaults to being false. Sorry, this is basically a rehash of what Paul said, but it seems that you possibly misunderstood his suggestion. Either that or I misunderstood your reply, which is also quite possible... :) - Luke PS Sorry if this message breaks threading; I wasn't subscribed to the list, so I had to copy and paste this.