incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Avi Flax <a...@arc90.com>
Subject Re: startkey_docid and "wildcard" paging
Date Sun, 01 Aug 2010 23:22:43 GMT
Thanks Chris.

I think you're saying that what I was trying isn't going to work.

Maybe if I share my actual use case, you might be able to point me in the
right direction.

I have keys in my view like this:

["a", "1", "2010-06-10T12:14:35Z"],
["a", "1", "2010-06-10T13:14:35Z"],
["a", "2", "2010-06-10T14:14:35Z"],
["a", "2", "2010-06-10T15:14:35Z"],
["b", "1", "2010-06-10T16:14:35Z"],
["b", "1", "2010-06-10T17:14:35Z"],
["b", "2", "2010-06-10T18:14:35Z"],
["b", "2", "2010-06-10T19:14:35Z"]

The first two elements are present because I want to filter by them — I want
to get rows for "a" and "2", for example. The third element is present
because I want the results sorted by date.

So — how can I add paging into this mix? What if I have 20 rows of "a" and
"2", each with a different date and a different doc_id, and I'm paging in
groups of 10 — if I can't use startkey_docid, then what can I do?

Thanks!
Avi

On Sun, Aug 1, 2010 at 19:10, J Chris Anderson <jchris@apache.org> wrote:
>
> On Aug 1, 2010, at 2:43 PM, Avi Flax wrote:
>
>> Hi all, quick question — i'm having a little trouble with paging with
>> startkey_docid
>>
>> I have a view whose keys look like: ["foo", "bar",
"2010-06-10T12:14:35Z"]
>>
>> I'm querying the view with startkey=["foo", "bar"] and
endkey=["foo","bar",{}]
>>
>> Which is returning what i expect, but i'm having trouble doing paging
>> with this scenario; it almost seems like startkey_docid is being
>> ignored.
>>
>
> startkey_docid is only useful when paging through a view where there are
more rows emitted for key X than your page size.
>
> startkey_docid is subservient to the key. the internal implementation of
collation looks like:
>
> [key, docid]
>
> so in your case
>
> [ ["foo", "bar", "2010-06-10T12:14:35Z"], docid]
>
> so the startkey_docid only has any effect when the key is an exact match
for the emitted key.
>
> I hope that helps.
>
> Chris
>
>> Any ideas?
>>
>> Thanks,
>> Avi
>>
>> Avi Flax » Partner » Arc90 » http://arc90.com
>> Kindling: Innovation through Collaboration » http://kindlingapp.com
>
>

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