couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nborwan...@gmail.com
Subject Re: couchdb soriting with value question?
Date Sun, 21 Jun 2009 06:17:44 GMT
If you're going to pull the results of the group=true query into say python, then you might
as well do the sorting in python. There are a number of commonly known approaches to sorting
a dict by value in python (and I'm sure in ruby as well). 
Nitin
Sent via BlackBerry by AT&T

-----Original Message-----
From: Chris Anderson <jchris@apache.org>

Date: Sat, 20 Jun 2009 08:13:16 
To: <user@couchdb.apache.org>
Subject: Re: couchdb soriting with value question?


On Sat, Jun 20, 2009 at 12:49 AM, hhsuper<hhsuper@gmail.com> wrote:
> Thanks Jan,
>
> when i need to paginate the data queried from view, you mean the sorting and
> paginating should all outside the couchdb?

Sorting by value is mathematically tough, if you want to read more
about the underlying issues check out
http://labs.google.com/papers/sawzall.html

If you can live with the sorted order being out of date, the simplest
thing to do is copy the results of a group=true query to another
database (via a scripting language like ruby or python) and then use a
view to sort those results by value. It won't be incrementally updated
as records are updated in the original database, but it will give you
an exact ordering by value.

We are thinking of building something like this into CouchDB because
it is such a common query, but for now you've got to do it yourself.

Chris

>
> On Sat, Jun 20, 2009 at 3:39 PM, Jan Lehnardt <jan@apache.org> wrote:
>
>>
>> On 20 Jun 2009, at 03:05, hhsuper wrote:
>>
>>  Hi,
>>>
>>> i have a view (impl with map/reduce function), the value need to be
>>> caculated in reduce function(for group reason etc.), and then how could i
>>> sorting by the value column?
>>>
>>
>> You need to sort by value outside of CouchDB.
>>
>> Cheers
>> Jan
>> --
>>
>>
>>
>
>
> --
> Yours sincerely
>
> Jack Su
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io
Mime
View raw message