The only thing to add is that the view indexes are sorted by your (possibly complex) keys. You always retrieve a contiguous portion of the view by either using just ?key= or both startkey and endkey.
Depending on the actual data you want to filter / sort / aggregate by, you can always come up with 'smart' complex keys where the data you need ends up together, one query away. An example would be to retrieve a single user's posts from 2011 Feburary. If your keys contain [username, date_posted] and your dates strings sort chronologically, you can easily query for all posts posted by a single user in a timeframe: ?startkey=["nils", "2011-02-01"]&endkey=["nils","2011-02-28"] If instead, you would also want ALL posts from february from all users, you would index by having the date come first, so ?startkey=["2011-02-01"]&endkey=["2011-02-28"] yields exactly what you want. On Mar 29, 2011, at 8:25 AM, Nils Breunese wrote: > Keys can be so called 'complex' keys. You could emit [username, tag] as the > key for your view entries and then request > /_design/designname/_view/by_username_and_tag?key=["username","tag"] to do > the lookup. > > Nils. > ________________________________________ > Van: bryan rasmussen [[email protected]] > Verzonden: dinsdag 29 maart 2011 8:03 > Aan: [email protected] > Onderwerp: how to get documents by two or more keys? > > As per the subject - most of my requests can be done with simple views > but I have some cases where I will want to return for multiple keys - > for example where I want to return documents for a username where > there is a particular tag value? > > Thanks, > Bryan Rasmussen > ------------------------------------------------------------------------ > VPRO www.vpro.nl > ------------------------------------------------------------------------
