On Wed, Aug 26, 2009 at 11:55:24AM +0200, Daniel Trümper wrote:
> the view reference in the wiki tells me that there is an option
> "startket_docid". Unfortunately there is not that much documentation
> about this specific option.
Internally, couchdb uses [key, docid] as the keys in the btree. So if you
have three docs which all do emit("X", null); then they come out as
["X","docid1"]
["X","docid2"]
["X","docid3"]
i.e. the docs are ordered first by key and then by their docids as a
secondary key.
When you do startkey="X" you are basically searching from ["X",null]
When you do startkey="X"&startkey_docid=docid2 then you are searching
from ["X","docid2"]
This pairing of keys and docids is for the most part hidden, but it reveals
itself in reduce functions:
function(keys, vals, rereduce) {
...
}
I believe you'll find that the 'keys' argument is actually
[[key,docid], [key,docid], ...]
(except for rereduce when it's null)
Regards,
Brian.