couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J Chris Anderson <jch...@apache.org>
Subject Re: Filtering of view results
Date Mon, 13 Sep 2010 21:11:20 GMT

On Sep 13, 2010, at 12:12 AM, Henrik Skupin wrote:

> 
> But how can I re-use the view to only show results for branch:4.0 sorted by
> date or even combined branch:4.0 & platform=Mac? I tried with
> ?key=[{},"4.0",{}] but none results get returned. Does the key option not
> allow to specify catchall values? Sadly I can't find any information about
> the usage of key.
> 

The solution is to relax and make 4 views, one to support each of the queries you describe:
all by date // branch by date // branch && platform by date // platform by date

Eg, there would be a view each, with emit calls like this:

1) emit(doc.timestamp, foo)
2) emit([doc.branch, doc.timestamp], foo)
3) emit([doc.branch, doc.platform, doc.timestamp], foo)
4) emit([doc.platform, doc.timestamp], foo)

This will give you the best performance.

Views in CouchDB are just sorted structures. That is, the rows are sorted on insert. This
means that queries are fast when they return contiguous ranges of rows. Queries which attempt
to return non-contiguous ranges of rows would be slow, so CouchDB does not support them.

I could show you a complicated way to achieve the API you are asking for, using _list functions,
but it would be slow, so I won't.

Chris

> I hope that is somehow possible.
> 
> Thanks,
> 
> -- 
> Henrik Skupin
> QA Engineer
> Mozilla Corporation


Mime
View raw message