From user-return-2172-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Wed Dec 17 16:06:27 2008 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 74107 invoked from network); 17 Dec 2008 16:06:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Dec 2008 16:06:27 -0000 Received: (qmail 21292 invoked by uid 500); 17 Dec 2008 16:06:38 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 21251 invoked by uid 500); 17 Dec 2008 16:06: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 21240 invoked by uid 99); 17 Dec 2008 16:06:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Dec 2008 08:06:38 -0800 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 paul.p.carey@gmail.com designates 74.125.78.25 as permitted sender) Received: from [74.125.78.25] (HELO ey-out-2122.google.com) (74.125.78.25) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Dec 2008 16:06:24 +0000 Received: by ey-out-2122.google.com with SMTP id 6so431613eyi.29 for ; Wed, 17 Dec 2008 08:06:03 -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:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=eB3vLtZswQPYBT7gM6pFUMRGYBg5HNZZV8uKEK/iJ4M=; b=j2PXasP/1DS7ZKUhSV1vuN1TPK7eW6c3YF6P1ZlPSHBfm6i4W64TS8lCDgYN1r5reY HDxreKjgKoYKkb6b2g5OzhSmocRwgdOyaUzQUp1Kz0DiLD1LViqYyD0Qtp3VlMtBcxnz Ojz253c8KrnGfrvZSKBzpjG7XVOKolzMCDxT0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=dfYin3hEvLbaL9EHl72ZVRX3s08k9AYA92Eu5C1B1fU/6mGg2Ms9yfAOjbJEcjdn91 uLU/SDhbWMk8vEAKydMxGsS+C9CSqGzYUWqzRkTvCLMmK5QITD2qy/qBH7jPTBzSdzT8 RsvNRdh+M7s6RVyErSdiXVCWvYcZrSZJ5+HUw= Received: by 10.67.22.2 with SMTP id z2mr3474017ugi.80.1229529963559; Wed, 17 Dec 2008 08:06:03 -0800 (PST) Received: by 10.66.248.20 with HTTP; Wed, 17 Dec 2008 08:06:03 -0800 (PST) Message-ID: <13ae4dd50812170806r5f18a71cs9c64afca0192c40c@mail.gmail.com> Date: Wed, 17 Dec 2008 16:06:03 +0000 From: "Paul Carey" To: user@couchdb.apache.org Subject: Re: Arguments for Reduce function In-Reply-To: <64de5c8b0812170743s3b80855eg451b96300eac6895@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <64de5c8b0812170743s3b80855eg451b96300eac6895@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Raj At a guess you're trying to get the doc count based on a particular characteristic of the doc. You might want to try something like function (doc) { emit(doc.i, doc); } function (keys, vals) { return sum(vals); } and then query with something like /my_db/_view/app/by_i?startkey=null&endkey=pivot /my_db/_view/app/by_i?startkey=pivot&endkey={} varying pivot as you wish. If you wanted to see all the docs, simply query with reduce=false Also your reduce function probably wouldn't behave as you'd expect when invoked as a rereduce - at some point the values param would be [values.length, a, b] array returned from a previous invocation. Hope this helps Paul On Wed, Dec 17, 2008 at 3:43 PM, Rajkumar S wrote: > Hi, > > I have a (simplified) reduce function like > > > function(key,values){ > var a,b; > for (var i=0; i< values.length; ++i) { > if (values[i] < 6){ > a++; > } else { > b++; > } > } > } > return [values.length,a,b]; > } > > The value 6 here is hard coded, is it possible to pass this via some > sort of arguments? Also how can I retrieve all results of a view ? > > Thanks and regards, > > raj >