couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathieu Castonguay <mcastong...@justlexit.com>
Subject Re: question about ranges
Date Mon, 23 Apr 2012 18:42:38 GMT
Ok I understand.

So how you would you do two checks then, as far as I know there is no
equivalent of "AND" and the only way to do this is to do two seperate
queries and then join the results (ie do my first range and then second
range and combine the results).

Is there a way to do this in a single query?

On Mon, Apr 23, 2012 at 2:31 PM, Robert Newson <rnewson@apache.org> wrote:

> Sure. CouchDB views are one dimensional, sorted by the full key. Your
> query will return all rows with a key equal to or greater than
> [52000,0] and less than [74000,64000]. This includes [71400,72200] as
> 71400 is greater than 52000 and less than 74000.
>
> http://wiki.apache.org/couchdb/View_collation
>
> B.
>
> On 23 April 2012 19:27, Mathieu Castonguay <mcastonguay@justlexit.com>
> wrote:
> > I have a very simple model with a list of lists of integers, ie
> > [[11000,20000],[23000,40000],[61400,62200],[71400,72200]]
> >
> > I have a view which loops through these and emits them
> >
> > "test6": {
> >           "map": "function(doc) { if (doc.ranges) { for (var x in
> > doc.ranges) { emit(doc.ranges[x], doc._id) }}}"
> >       },
> >
> >
> >
> > and then I basically want to pull the ones that are within my range:
> >
> > test6?startkey=[52000,0]&endkey=[74000,64000]
> >
> > this returns:
> >
> > {"total_rows":7,"offset":5,"rows":[
> >
> {"id":"059a2e3b15364dcdfe412a6998021832","key":[61400,62200],"value":"059a2e3b15364dcdfe412a6998021832"},
> >
> {"id":"059a2e3b15364dcdfe412a6998021832","key":[71400,72200],"value":"059a2e3b15364dcdfe412a6998021832"}
> > ]}
> >
> >
> > But what I was expecting is to only see the [61400,62200] because i
> thought
> > that with this query I was doing [Between(52000,74000),Between(0,64000)]
> >
> > There's obviously something wrong with my logic, can someone lend a hand?
>

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