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 0ECB61735C for ; Sun, 5 Oct 2014 19:01:16 +0000 (UTC) Received: (qmail 62443 invoked by uid 500); 5 Oct 2014 19:01:14 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 62383 invoked by uid 500); 5 Oct 2014 19:01:14 -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 62366 invoked by uid 99); 5 Oct 2014 19:01:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2014 19:01:14 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of siriele2x3@gmail.com designates 209.85.216.177 as permitted sender) Received: from [209.85.216.177] (HELO mail-qc0-f177.google.com) (209.85.216.177) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2014 19:01:10 +0000 Received: by mail-qc0-f177.google.com with SMTP id c9so3024293qcz.8 for ; Sun, 05 Oct 2014 12:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=jwmQfqceUcN6XZsRLptg8BeBi3+EAu22h0he1t44XbM=; b=N/6ahp+A1JJZAv0amw1kGwUnq9wuCGPtOOHCZjx3m3H6Gu3pFaSes1+qiIhIMQWjHl nhJCRP6J6s28T3EpRBtxg99rvbWvf+oZz9XWLhIz1LhB9d69yLv5vK/Z6f5rVYs3Mtui ROHs0sFhk1VX/glzl2UHKKbX95wsi/+xss+L5KbYUjmopnT/3rB8lcaG1uGlZtdut9Hc u7OYsNl9T0Cs3dXktFNNh4TqDBLfRiIiFY6cmJXJhMiPjCVlSXJlOHx3aIPevNOk0GZs hBo6aFjKBOgUSPHy9LJMEPdPDoa2WOGqmvIRmZxucx+W1J0YSSYq612x+P1tDxCd3WY8 1YYw== MIME-Version: 1.0 X-Received: by 10.229.250.71 with SMTP id mn7mr8939769qcb.25.1412535649555; Sun, 05 Oct 2014 12:00:49 -0700 (PDT) Received: by 10.96.98.135 with HTTP; Sun, 5 Oct 2014 12:00:49 -0700 (PDT) In-Reply-To: References: Date: Sun, 5 Oct 2014 12:00:49 -0700 Message-ID: Subject: Re: View question From: Stanley Iriele To: user@couchdb.apache.org, Giovanni Parra Content-Type: multipart/alternative; boundary=001a11343aec9fd9650504b19527 X-Virus-Checked: Checked by ClamAV on apache.org --001a11343aec9fd9650504b19527 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable chaining map reduce sounds really exciting....but for your current solution...list functions would be the way to go On Sun, Oct 5, 2014 at 10:03 AM, Giovanni P wrote: > as I always have trouble imagining the results of a some reduce function > with group_level and stuff alike, I made this app for quickly simulating > these things: http://fiatjaf.github.io/couchdb-mr-simulator/ > > here's the same simulation Aur=C3=A9lien did: > > http://fiatjaf.github.io/couchdb-mr-simulator/#{%22params%22:%22reduceFn:= %20_count\nreduce:%20true\ngroup:%20true\ngroup_level:%202\nstartkey:%20[20= 13]\nendkey:%20[2014,%20{}]%22,%22emitted%22:%222012,%20\%22A\%22\n2012,%20= \%22B\%22\n2012,%20\%22C\%22\n2013,%20\%22A\%22\n2013,%20\%22A\%22\n2013,%2= 0\%22A\%22\n2013,%20\%22C\%22\n2014,%20\%22A\%22\n2014,%20\%22A\%22\n2014,%= 20\%22B\%22%22} > < > http://fiatjaf.github.io/couchdb-mr-simulator/#%7B%22params%22:%22reduceF= n:%20_count%5Cnreduce:%20true%5Cngroup:%20true%5Cngroup_level:%202%5Cnstart= key:%20[2013]%5Cnendkey:%20[2014,%20%7B%7D]%22,%22emitted%22:%222012,%20%5C= %22A%5C%22%5Cn2012,%20%5C%22B%5C%22%5Cn2012,%20%5C%22C%5C%22%5Cn2013,%20%5C= %22A%5C%22%5Cn2013,%20%5C%22A%5C%22%5Cn2013,%20%5C%22A%5C%22%5Cn2013,%20%5C= %22C%5C%22%5Cn2014,%20%5C%22A%5C%22%5Cn2014,%20%5C%22A%5C%22%5Cn2014,%20%5C= %22B%5C%22%22%7D > > > > On Sun, Oct 5, 2014 at 9:05 AM, Aur=C3=A9lien B=C3=A9nel > wrote: > > > > Thanks Aur=C3=A9lien for a better explanation of my problem :-) > > > > Good to hear :) > > > > For the additional computation step, you can: > > > > 1. switch to CloudAnt's BigCouch to get chained mapreduce > > http://examples.cloudant.com/sales/_design/sales/index.html > > > > 2. or wait for BigCouch integration into Apache CouchDB (in version 2.0= ) > > https://issues.apache.org/jira/browse/COUCHDB/fixforversion/1231557= 2 > > > > 3. or "cheat" and do it with a list. > > > > > > Regards, > > > > Aur=C3=A9lien > > > > > > >>>> I need to filter by date and group by group... > > >>> You can use the second with group_level=3D1 and get all the groups = at > the > > >> same time. And you can use _count > > >> > > >> > > >> I'm afraid this is not so easy... > > >> Using a filter by date will also *group* by date. > > >> > > >> Let's take a very simple example... > > >> > > >> Here are keys emitted by a map: > > >> [2012, 'A'] > > >> [2012, 'B'] > > >> [2012, 'C'] > > >> [2013, 'A'] > > >> [2013, 'A'] > > >> [2013, 'A'] > > >> [2013, 'C'] > > >> [2014, 'A'] > > >> [2014, 'A'] > > >> [2014, 'B'] > > >> > > >> If we query it with `_count` as the reduce function, `group=3Dtrue`, > > >> `startkey=3D[2013]` and `endkey=3D[2014,{}]`, we'll get: > > >> [2013, 'A'] -> 3 > > >> [2013, 'C'] -> 1 > > >> [2014, 'A'] -> 2 > > >> [2014, 'B'] -> 1 > > >> > > >> Boaz will need additional computation to get: > > >> 'A' -> 5 > > >> 'B' -> 1 > > >> 'C' -> 1 > > >> > > >> > > >> Regards, > > >> > > >> Aur=C3=A9lien > > > > > --001a11343aec9fd9650504b19527--