Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 96900 invoked from network); 23 Nov 2009 18:54:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Nov 2009 18:54:33 -0000 Received: (qmail 89347 invoked by uid 500); 23 Nov 2009 18:54:32 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 89258 invoked by uid 500); 23 Nov 2009 18:54:32 -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 89248 invoked by uid 99); 23 Nov 2009 18:54:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2009 18:54:32 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of szymon.kapeniak@gmail.com designates 209.85.219.210 as permitted sender) Received: from [209.85.219.210] (HELO mail-ew0-f210.google.com) (209.85.219.210) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2009 18:54:26 +0000 Received: by ewy2 with SMTP id 2so1924475ewy.35 for ; Mon, 23 Nov 2009 10:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=7jJYeTDALSvLwH3Hh52UkuEZk2CoFNwBVZQf1ohW77E=; b=a11vnjfykrxmg6bHm+sSus5NUPCP5DhuNw4rDtWfqYZw7Kq4NF6PYn3fYMCG1MbP9v Osm6/76oTJ5G2o8rGXkD72ufptfMFS2A/pQmWVtHsmvdJwijR/+tZZx4O6gYBrgT2GTZ WU1GsLX45cx8djrKYvJJsspGr86IXMZfopx0c= 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:content-transfer-encoding; b=M0hgEuDuWImN+8Sk63usBBPS9lVa741KwnZliKczfW4kqtW0dn1E/iVAG3GzenUsEL Mv0L6jilwvJxv1tplfTEhWy5clTxi2AJZ3C9WZHzHvE84AZ2ABV3YLCGF4Zgtsk5iAoq x6NAUnbL4s0+LdHO3p7FkSWb69TGfDqhbBfVo= MIME-Version: 1.0 Received: by 10.213.23.155 with SMTP id r27mr3994857ebb.48.1259002443690; Mon, 23 Nov 2009 10:54:03 -0800 (PST) In-Reply-To: <20091123130025.GA10729@uk.tiscali.com> References: <4B09B3EC.3090002@gmail.com> <20091123130025.GA10729@uk.tiscali.com> Date: Mon, 23 Nov 2009 19:54:03 +0100 Message-ID: <622cacf50911231054p1c807c59q3be53d57c7f45d7f@mail.gmail.com> Subject: Re: How to get nested-key-sorted collection of documents From: Szymon Kapeniak To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thank you both, it helps a lot. I'll try this approach soon. One question I have is in which version of couchdb group_level was introduc= ed? I currently work on 0.8... 2009/11/23 Brian Candler : > On Mon, Nov 23, 2009 at 08:58:04AM +1100, Mark Hammond wrote: >> Here your map function looks something like: >> >> emit([doc.author, doc.date], null); >> >> Your rows will then be returned, with the _id, in order of author and >> date. =A0You could query like: >> >> startkey=3D["Tolstoj", 1985], endkey=3D["Tolstoj", 1999] >> >> To query a range of dates for a single author. > ... >> Very similar: >> >> emit([doc.author, doc.date, doc.publisher], null); >> >> By using the group_level capability (see the wiki about the view API), >> you could still search just by author, by author and date, or by all 3 >> fields. > > And of course you could use this view for the first query as well. A quer= y > for > > =A0startkey=3D["Tolstoj"]&endkey=3D["Tolstoj", {}] > > will still find all the relevant rows - it's just that this time they wil= l > be sorted by publisher and then _id, rather than just _id. > > If you have a reduce function (e.g. which counts books), then using > group_level=3D2 would give you counts by author and year, independent of > publisher. >