couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <>
Subject Re: how do I do different reduce operations on the same map
Date Wed, 11 Feb 2009 20:08:39 GMT
On Tue, Feb 10, 2009 at 02:31:58PM -0800, James Marca wrote:
> I have a situation where I want to run two different reduce functions
> on the output of a single map function.  Like suppose I want one
> reduce function to get the count of all objects in each group (for
> example, documents with or without attachments), and another reduce to
> compute some other aggregate, like the average and standard deviation
> of a value, (like the average size of attached documents).  (Yes, I
> know this is a stupid example, as the averaging reduce function will
> also have the count, but my real case is too complicated to write
> easily).

I believe reduce values are any JSON object, so perhaps you could reduce to
an array of values, e.g. [count, total, sum_of_squares]

The final calculation of average and SD could then be left to the client

View raw message