View that can Order by "A" but filter by "B"


#1

How do you make a view that can order by a field A but filter by B?

I have a view that need to be sorted by date, but then I need to set the startkey on another field.
I have read that with compound keys you can’t ignore the first values, so the only option is to load all the keys in memory and do the filtering myself?!
This seem a pretty serious limitation.

Any workaraund?


#2

Functionally, the filtering work is approximately the same whether it’s done at the client or the server. Depending on the client you’re using (both .NET and Java make this quite easy) it wouldn’t be too bad to filter.

Also, note that the new query features we have coming soon in N1QL will make this easier to express. It may not necessarily be faster or more efficient, depending on the set of data, what’s indexed, etc.


#3

To filter locally I have to load all docs every time, and to be sure to not run out of memory I need to query in batches.
Isn’t server filtering smart with sort of direct access to data if you specify a startkey?
From my understanding it doesn’t loop through the whole dataset.

Speaking of N1QL now that you are preparing Couchbase 4, will it be out officially for 3.0 too or once final it will ship with 4.0 only?