Couchbase view with composite keys : How to set the right startkey/endkey range?


#1

Having this document structure:

“document”:{
“title”:"Cheese ",
“start_date”: “2010-02-17T15:35:00”,
“source”: “s_source1”
}

I would like to create a view that return all documents ids between 2 dates and for a certain source:

function (doc, meta) {
emit([doc.start_date,doc.source], null);
}

I tried to use this range key to get all document of source 1 between “2014-04-04” and “2014-04-05”:

startkey=["2014-04-04","s_source1"]&endkey=["2014-04-05","s_source1"]

But this don’t work for the sources. It retrieves me all document for the date range but for all sources ( s_source1,s_source2,…) .

I guess that the underscore is the source of problem( some encoding issue)?

How should I set my key range to get only documents of a unique source for a certain date range?