couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Davis" <paul.joseph.da...@gmail.com>
Subject Re: Top 10 sorted by value...
Date Wed, 01 Oct 2008 02:17:06 GMT
Using your 'key', 'value' definitions:

emit([value, key], null)

The top 10 is:
http://localhost:5984/db/_view/my-view/name?count=10&reverse=true

Paging through:
http://localhost:5984/db/_view/my-view/name?count=11&reverse=true&startkey=last_value_of_previous_get

You could use offset=10, but when offset > say, 1M, this will be
unberably slow, where startkey would be fast like lightning.

You'll want to double check my reverse=true option, I'm pretty certain
that's right, but I'm a bit tired.

On Tue, Sep 30, 2008 at 8:54 PM, kowsik <kowsik@gmail.com> wrote:
> I have a data set where my map reduce returns data like so:
>
> { key: "a", value: 10 },
> { key: "b", value: 12 },
> { key: "c", value: 1 },
> ...
>
> Potentially this could be fairly large, even after the reduce. Is
> there any way to:
>
> 1. sort these by descending values? I only want the top 10.
> 2. page through them in the sorted order?
>
> I realize that the descending=true works only on the keys.
>
> Thoughts?
>
> K.
>

Mime
View raw message