actually, it's responding exactly as expected.

you can't think of complex keys as a boolean "AND", but as a single value.



is actually less than ALL your values because of CouchDB's collation rules.

To explain this to others, I use the idea of turning the key into a sentence.... typically i think of it as you have the last element grouped by the the other elements from left to right.

So you have "restaurantids grouped by timestamp" as your key, which means for any given timestamp as a startkey/endkey, the last item in the key will be a restuarantid... if you try rounding your timestamp to the nearest hour in your example you'll see what I mean using your data... 

if you want to look up by restaurantid, order your keys from left to right... [restaurantid, timestamp]... which will then order your view first by restaurantid, then by timestamp... which gives you "timestamps grouped by restaurantid"

you'd then use


- Jim

Jim Klo
Senior Software Engineer
Center for Software Engineering
SRI International

On Feb 29, 2012, at 3:45 PM, Mathieu Castonguay wrote:

Here is the view:

  "restaurant_orders_after_date": {
      "map": "function(doc) { if(doc.restaurantId &&
doc.timeOfLatestStatusChange && doc.status && (doc.status == 'ACCEPTED' ||
doc.status == 'REJECTED')) {
emit([doc.timeOfLatestStatusChange,doc.restaurantId], doc._id)}}"

Execution of the view:



It seems to completly ignore the second value which is the id of the
restaurant. I want all orders who's timeOfLatestStatusChange is greater
than the current time (in this case "2012-01-01T02:07:50.387+0000") and
who's restaurant id is a certain value(in this case

Can anyone explain to me why the second parameter seems ignored, I can mean
I can put "donkey" and it still does the same thing.

Thank you,