From user-return-16532-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Tue Jun 7 06:50:50 2011 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 01C896238 for ; Tue, 7 Jun 2011 06:50:50 +0000 (UTC) Received: (qmail 1892 invoked by uid 500); 7 Jun 2011 06:50:48 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 1859 invoked by uid 500); 7 Jun 2011 06:50:48 -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 1851 invoked by uid 99); 7 Jun 2011 06:50:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2011 06:50:48 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of marcello.nuccio@gmail.com designates 209.85.212.52 as permitted sender) Received: from [209.85.212.52] (HELO mail-vw0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2011 06:50:42 +0000 Received: by vws16 with SMTP id 16so4988787vws.11 for ; Mon, 06 Jun 2011 23:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=KIvT1bK/97x9bnwU7rhrKmHSqFjnNHtMAUXJFdOhwDg=; b=l7FfTcC05iGhM+K7Gnow/HZirC9BpgzxXMRWE/6/aXXVEAT5tkR/rmLNwUIaOyy47R VnNuE7sdteMLUZjE8bvkI9fCb8EnBt/GYnzBtfXa5kzBPnEh8rZx8sd4o1yyyNgFLP0J FBuGRNIq+l9ZymRSiCRm/9lBwtt0zc8lCWgtQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=VKyeip3yMW76u16ZkBkAASxBKIqsZlD2C3XtXDchVrQLCZUFsEQWnXxAU+APYQFIlg e3Ur5oAfuPD9ERfq4wjzV7VVXNFtWaT7pzud6e57VKYBCv62yGdxOq012+8zlc6vO/Pz bTe0D2iN73sGMhk4FVjAp3cg9CMWxj5JuqwJc= MIME-Version: 1.0 Received: by 10.52.175.132 with SMTP id ca4mr985282vdc.98.1307429420044; Mon, 06 Jun 2011 23:50:20 -0700 (PDT) Received: by 10.52.159.200 with HTTP; Mon, 6 Jun 2011 23:50:20 -0700 (PDT) In-Reply-To: <4DEDC36C.5090207@gmail.com> References: <4DDDFD4E.9060701@gmail.com> <4DDF164A.7030009@gmail.com> <4DDF6BEE.8070907@gmail.com> <4DE4F6F4.9000406@couchone.com> <4DECC426.9070201@gmail.com> <4DEDC36C.5090207@gmail.com> Date: Tue, 7 Jun 2011 08:50:20 +0200 Message-ID: Subject: Re: Complex queries & results From: Marcello Nuccio To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org 2011/6/7 Torstein Krause Johansen : > I'm still puzzled, though. When reading up on reduces, I got put off doing > anything fancy in the reduce function as the guide on > http://guide.couchdb.org/draft/views.html#example/3 states: > > "A common mistake new CouchDB users make is attempting to construct complex > aggregate values with a reduce function. Full reductions should result in a > scalar value, like 5, and not, for instance, a JSON hash with a set of > unique keys and the count of each." > > And from my understanding, this is exactly what I want to do here, but > perhaps I'm misunderstanding the author's meaning here? In my experience it is not a problem for a reduce function to return an hash. The strict requirement for reduce functions, is to actually reduce the data it get passed to a small constant size value, be it a scalar or an object. You can look at this example for an idea of what I mean http://stackoverflow.com/questions/5637412/getting-a-list-of-documents-with-a-maximum-field-value-from-couchdb-view/5654154#5654154 I hope to be corrected if I am wrong. Marcello