couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <rnew...@apache.org>
Subject Re: question about ranges
Date Mon, 23 Apr 2012 18:31:26 GMT
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
View raw message