Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 37793 invoked from network); 29 Sep 2009 20:01:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Sep 2009 20:01:11 -0000 Received: (qmail 91731 invoked by uid 500); 29 Sep 2009 20:01:10 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 91687 invoked by uid 500); 29 Sep 2009 20:01:10 -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 91677 invoked by uid 99); 29 Sep 2009 20:01:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Sep 2009 20:01:10 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of glenn@rempe.us designates 209.85.210.176 as permitted sender) Received: from [209.85.210.176] (HELO mail-yx0-f176.google.com) (209.85.210.176) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Sep 2009 20:01:00 +0000 Received: by yxe6 with SMTP id 6so6804672yxe.13 for ; Tue, 29 Sep 2009 13:00:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.91.76.5 with SMTP id d5mr3879993agl.68.1254254439084; Tue, 29 Sep 2009 13:00:39 -0700 (PDT) In-Reply-To: <8a02878f0909290917u22d79ed7p161448fc586b2a8d@mail.gmail.com> References: <7c40ded80909280714i203cedb3gbfbfb874aebbd187@mail.gmail.com> <7c40ded80909280721g86ef6cbx8182d652959b772c@mail.gmail.com> <8a02878f0909280925r63659831u10cf2d687d6a1760@mail.gmail.com> <8a02878f0909280931n7e7b226apd74549ed70987158@mail.gmail.com> <6cfccb3d0909281351l6ec5bdtcb2b4cba9919d8e9@mail.gmail.com> <8a02878f0909290917u22d79ed7p161448fc586b2a8d@mail.gmail.com> From: Glenn Rempe Date: Tue, 29 Sep 2009 13:00:18 -0700 Message-ID: <6cfccb3d0909291300g76c3f394wde685e6ecae38c29@mail.gmail.com> Subject: Re: Help with complex key range query and map/reduce To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0016e64606524cb43e0474bcde61 X-Virus-Checked: Checked by ClamAV on apache.org --0016e64606524cb43e0474bcde61 Content-Type: text/plain; charset=UTF-8 Thanks Jesse for helping me walk through this. I think I am (slowly) wrapping my head around it. :-) I think your example of having two different views to cover this is helpful. Let me replay, and tell me if I may finally have it. (Just a note to clarify my use case, the date ranges can be an arbitrary number of days e.g. Today - 60 days, and not strictly tied to one month at a time on the natural monthly boundaries). # Break up the views by *either* ALL engines, or a *SPECIFIC* engines. A different view for each. The view executed is based on whether the engine is all or specific. # View 1 : When you want to query a single category (1), ALL engines, and a date range of 8/1 - 9/30: # [1,2009,8,1] to [1,2009,9,30] # View 2 : When you want to query a single category (1), a SPECIFIC Engine, and a date range of 8/1 - 9/30: # [1,"g", 2009,9,1] to [1,"g",2009,9,30] Correct? Thanks again. Hopefully I've got it now. Glenn On Tue, Sep 29, 2009 at 9:17 AM, Jesse Hallett wrote: > Glenn, > > I am afraid that to do what you want to do you will need at least two > different views. As Ning explained, the most significant position of the > key determines what will be filtered. For example: > > start: [1, 2009, 9, 1, "g"] > end: [1, 2009, 9, 29, "g"] > > Will return all results for September with cat_id 1, regardless of engine, > except that it will exclude items from 9/1 with engines "a"-"f" and items > from 9/29 with engines "h"-"z". To demonstrate this, consider these > ordering facts: > > [1, 2009, 9, 5, "r"] > [1, 2009, 9, 1, "g"] // 5 > 1 > [1, 2009, 9, 23, "m"] < [1, 2009, 9, 29, "g"] // 23 < 29 > > That is why it is necessary to move the engine parameter in front of the > date. If you want the options of filtering by a specific engine or > including all engines in a given date range you will need two different > views that have keys that are ordered differently. If you want a specific > range of engines you will have to lock that query to a specific date > parameter. But you can for example create a view that only emits year and > month values for the date to query based on a specific range of engines > over > one month. > > --0016e64606524cb43e0474bcde61--