Startkey & endkey : strange result


I’m trying to get a view with startkey and endkey parameters but i’ve strange results.

My view :

function (doc, meta) {
emit([, doc.request_time], { “id” :, “group” :, “message”:doc.message, “level”: doc.level, “url”:doc.url, “sbt”:doc.sbt, “request_time”:doc.request_time, “site_id”:doc.site_id });
} = 28
doc.request_time = 1272817191 (timestamp)

and the query :


startkey=[24, 1]
endkey= [31, 1272817191]

In fact, i want docs which their id > x et request_time < x. I have trouble to do this, so i try to do id >24 and <31 and request_time >1 and < 1272817191. Look the result (i just put keys result) :


I don’t understand why 25, 26, 27, 28 are return…

Thanks for helping

Couchbase has only one index. So you can’t filter by two ranges. See this for more detailed answer:

PS. May be it’s a good idea to add such question to some FAQ.

Ok, i understand.

So can i do a endkey=126782 and startkey_docid= 21 to have all documents which have a request_time less than 126782 and the id greater than 21 ?

But if you have sequential ids and you have all docs before doc with id=21 you can try to use skip param to skip previous 20 docs and start from doc_id=21.

Oh, I don’t know. Param startkey_docid never worked for me and I don’t know if it works at all :).