incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Miller <apag...@ninjawhale.com>
Subject Re: Filtering of view results
Date Thu, 23 Sep 2010 08:04:27 GMT
If date is what you want to sort by and you don't mind not being able to
intersect filters you can use your complex keys like this (emitting multiple
rows per doc), and you'll only need the one view:

emit(["branch",doc.branch,doc.date);
emit(["platform",doc.platform,doc.date);

Then you can query
/whateverview?startkey=["branch","4.0"]&endkey=["branch","4.0",{}]

The combined filtering is not currently possible. If you -really- need it
you can http://en.wikipedia.org/wiki/Merge_join on the client side as long
as you can collate whatever you're sorting by on both "queries". In this
example, the doc.date field. The gist of it is that when intersecting two
datasets sorted by the same field you always know that there are no matches
in a set that appear before key the of the last element you looked at in the
other set, so you can rule out large chunks of data at a time for searching
through.

On Mon, Sep 13, 2010 at 12:12 AM, Henrik Skupin <hskupin@gmail.com> wrote:

> Hi,
>
> Using complex keys for my views gives me a problem with filtering the
> results. Lets say I have two filters:
>
> Branch: "All", "4.0", "3.6"
> Platform: "All", "Windows NT", "Linux", "Mac"
>
> Per default no filtering is active and all results get shown sorted by
> date.
> The key which is used for emit looks like:
>
> emit([doc.date, doc.branch, doc.platform], { ... }]);
>
> 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.
>
> I hope that is somehow possible.
>
> Thanks,
>
> --
> Henrik Skupin
> QA Engineer
> Mozilla Corporation
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message