couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ross Bates <rba...@gmail.com>
Subject Re: startkey/endkey and descending=true
Date Thu, 18 Jun 2009 15:55:06 GMT
Eureka! Thanks Paul and Blair - your examples and explanations make sense
and were very helpful.

-Ross



On Wed, Jun 17, 2009 at 8:11 PM, Paul Davis <paul.joseph.davis@gmail.com>wrote:

> Blair has the right idea here.
>
> descending=true quite literally means "traverse the btree backwards"
> and that is all. The side effect this has that catches a lot of people
> is that "traverse the btree backwards" means you have to swap your
> start and end keys because going backwards the logic is swapped. Or in
> other words, "start" means "encountered first, given the current
> traversal direction".
>
> HTH,
> Paul Davis
>
> On Wed, Jun 17, 2009 at 8:04 PM, Blair Nilsson<blair.nilsson@gmail.com>
> wrote:
> > I shouldn't drink so much coffee before posting, some of that didn't
> > make too much sense.
> >
> > take the keys
> > ["a",1]
> > ["a",2]
> > ["a",3]
> > ["b",1]
> > ["b",3]
> > ["b",5]
> >
> > startkey=["a"]&endkey=["b"]
> > will give you all of the keys starting with ["a"]
> >
> > Any key after ["a",3] and before ["b",1] can be used.
> > {} is after any number, string or array (I think), so is very useful
> > to use as part of a key describing a range.
> >
> > startkey=["a"]&endkey=["a",{}] should give you anything under ["a"],
> > since it is the range containing going form the first to last possible
> > key for anything under ["a"]
> >
> > What that means when you use descending=true, you will need to start
> > with ["a",{}] and end with ["a"]
> >
> > Hopefully, this will make more sense, and that I have will remember to
> > read my posts before I post them :)
> >
> > Sorry for the hurried post before.
> >
> > --- Blair
> >
>

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