couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Rempe <gl...@rempe.us>
Subject Re: Help with complex key range query and map/reduce
Date Mon, 28 Sep 2009 21:15:39 GMT
So if I flipped it around as suggested to emit key/values of:
[cat, engine, year, month, day], {"val1":one, "val2":two}

# query a specific cat, a SPECIFIC engine, a RANGE of dates
startkey = [1, "g", 2009, 9, 1]
endkey = [1, "g", 2009, 9, 28]

# query a specific cat, a RANGE of engines, a RANGE of dates
startkey = [1, "a", 2009, 9, 1]
endkey = [1, "z", 2009, 9, 28]

# query a specific cat, a RANGE of engines, a RANGE of dates that cross a
year boundary
startkey = [1, "a", 2008, 12, 1]
endkey = [1, "z", 2009, 1, 30]

Will that do the trick?  Thanks all for helping me catch (and grok) the
error of my ways. :-)

Cheers,

Glenn


On Mon, Sep 28, 2009 at 2:00 PM, Ning Tan <ningtan@gmail.com> wrote:

> On Mon, Sep 28, 2009 at 4:51 PM, Glenn Rempe <glenn@rempe.us> wrote:
> >
> > startkey = [1, 2009, 9, 1, "g"]
> > endkey = [1, 2009, 9, 28, "g"]
> >
> > Would it not return category 1, across the entire date range, but limited
> to
> > those with the engine 'g' only?
>
> No. CouchDB keys are not filters. They occupy a linear space, and as
> long as a key is "larger" than (or equal to) the startkey and
> "smaller" than (or equal to) the endkey, the corresponding row is
> included in query results. In the above case, [1, 2009, 9, 1, "h"]
> will be included in your query result. There is a Wiki page on view
> collation that explains this.
>



-- 
Glenn Rempe

email                 : glenn@rempe.us
voice                 : (415) 894-5366 or (415)-89G-LENN
twitter                : @grempe
contact info        : http://www.rempe.us/contact.html
pgp                    : http://www.rempe.us/gnupg.txt

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message