Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 93395 invoked from network); 10 Jun 2008 16:00:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jun 2008 16:00:03 -0000 Received: (qmail 10619 invoked by uid 500); 10 Jun 2008 16:00:04 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 10600 invoked by uid 500); 10 Jun 2008 16:00:04 -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 10571 invoked by uid 99); 10 Jun 2008 16:00:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 09:00:04 -0700 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.152 as permitted sender) Received: from [74.125.46.152] (HELO yw-out-1718.google.com) (74.125.46.152) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 15:59:12 +0000 Received: by yw-out-1718.google.com with SMTP id 5so1730100ywr.0 for ; Tue, 10 Jun 2008 08:59:18 -0700 (PDT) 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=dy7kBZhCzXy/Xly9QcUinaFG9bEqo7i/3HSryOpWDoY=; b=cGtizdqsx58I4ruFBtHDn/YpLrbylp9q6gBEwGHY+P3tuUQuAvoENzcUidtg0CdTWN eDtUtN40IbNDojj6fQve4aJjI6sMZmRKGS2L0o5bjHWUX21dTCsvORerTeD5oGXG64Xm XFXjC9wnCbEQ/F8U5TwLyiSpOeNXzums/Dd28= 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=R6p8IWui4nTUF2H4CAsiZjtwTGI19ZnRt4wV2naqx9tLpoP7GfwVHELr10ifOloWEh pb4PXffU9/8tOoCshjJ+2gbgYp3iOqo5PqBk3/2pLOfR50A8sMqQHWg3osgB3PD9w7NO FQTX2f/ChGsm74SthFLpzswjQfaFJ95GkeKfI= Received: by 10.115.32.8 with SMTP id k8mr5129137waj.89.1213113557401; Tue, 10 Jun 2008 08:59:17 -0700 (PDT) Received: by 10.115.91.19 with HTTP; Tue, 10 Jun 2008 08:59:17 -0700 (PDT) Message-ID: Date: Tue, 10 Jun 2008 08:59:17 -0700 From: "Chris Anderson" Sender: jchris@gmail.com To: couchdb-user@incubator.apache.org Subject: Re: how to do it in couchDB In-Reply-To: <19e19e410806100024o57c94b78rcbb0b1058802352@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <19e19e410806100024o57c94b78rcbb0b1058802352@mail.gmail.com> X-Google-Sender-Auth: a923ac83f54cea93 X-Virus-Checked: Checked by ClamAV on apache.org On Tue, Jun 10, 2008 at 12:24 AM, Ryszard Szopa wrote: > The most natural way of solving this problem would be to first have a > view with a map emitting users and their scores, keyed by user_id, and > a reduce that groups a user and his results in one object, and *then* > run a query on this, mapping teams-names to lists of results and > reduce it to get the mean. Unfortunately, I have no idea if something > like this is possible in CouchDB. I'm planning to add some functionality to CouchRest, which will automatically take the results of a group=true reduce query, page through them, adding all the key/value pairs as documents in another database. I plan to call the functionality Remap - hopefully I'll have it written sometime this week. Writing additional queries as map/reduce views on the derived dataset would give you a lot of flexibility. For instance, writing maps across the Remap set would allow you to sort by group reduce value, making it easy to query on the popularity of certain items in the set - or total and average scores for a team, in your case. The only problem is that the second dataset won't automatically be kept up to date by CouchDB, and the nature of views makes it hard to refresh the derived dataset in any other way than by regenerating the whole thing (paging through the reduce set again.) Chris -- Chris Anderson http://jchris.mfdz.com