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 8D01478EC for ; Fri, 5 Aug 2011 22:35:11 +0000 (UTC) Received: (qmail 40655 invoked by uid 500); 5 Aug 2011 22:35:09 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 40620 invoked by uid 500); 5 Aug 2011 22:35:09 -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 40612 invoked by uid 99); 5 Aug 2011 22:35:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Aug 2011 22:35:09 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.82.54] (HELO mail-ww0-f54.google.com) (74.125.82.54) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Aug 2011 22:35:01 +0000 Received: by wwg9 with SMTP id 9so922781wwg.23 for ; Fri, 05 Aug 2011 15:34:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.220.219 with SMTP id o69mr976595wep.65.1312583680781; Fri, 05 Aug 2011 15:34:40 -0700 (PDT) Received: by 10.216.132.35 with HTTP; Fri, 5 Aug 2011 15:34:40 -0700 (PDT) X-Originating-IP: [41.132.126.215] In-Reply-To: References: Date: Sat, 6 Aug 2011 00:34:40 +0200 Message-ID: Subject: Re: View collation by one key and sorting by another key From: Matthew Slade To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0016364c7b9107ef1504a9c9b445 X-Virus-Checked: Checked by ClamAV on apache.org --0016364c7b9107ef1504a9c9b445 Content-Type: text/plain; charset=ISO-8859-1 Hi Randall Thanks, I'm aware of the ability to split out the date into multiple keys for easier collation. However that's not really the issue here. My problem is with the additional level of sorting that might be required to make the reduced data meaningful. ie I want to know only about oranges and not other fruit in my particular date time collation. Matthew On Sat, Aug 6, 2011 at 12:19 AM, Randall Leeds wrote: > On Fri, Aug 5, 2011 at 15:00, Matthew Slade > wrote: > > Hi Zach (and everyone else) > > > > Thanks for the info. Unfortunately my game is already big and the > proposed > > solution wouldn't really be suitable although _lists seem interesting and > > I'll definitely investigate them. I do find this quite a limitation to > > couchdb especially when one is working a lot with dated documents. > > > > Another question I have in a similar vein: > > > > Given a set of documents being created for transaction for the purchase > of > > fruit for example. > > > > * { > > "_id":"uniqueOrderId", > > "dateOfPurchase": "2011-07-06T10:24:52", > > "itemId": "oranges" > > }* > > > > Could one collate the view entries by the date and then reduce based off > of > > part of the value. ie How could I easily answer the question "*How many > > oranges were sold on Wednesday*?" efficiently with potentially huge > numbers > > of transaction documents in my database. > > You should separate the key you emit into an array of the date pieces > like [YYYY, MM, DD, ...]. > Then you can use ?group_level=X with your reduce query to get hourly, > daily, monthly, etc summaries. > > -Randall --0016364c7b9107ef1504a9c9b445--