couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Eggleston" <>
Subject Map Reduce aggregate queries
Date Wed, 30 Apr 2008 02:36:24 GMT

I recently tried explaining the power of map / reduce to someone,
using a simple example of adding up hours spent on a project over a
period of time.

The output of the mapping function would be:

key, value

4/28/2008, 1
4/28/2008, 4
4/29/2008, 7
4/29/2008, 3

The output of the reduce function would be:

key, value

4/28/2008, 5
4/29/2008, 10

Shouldn't I then be able to issue a query for an arbitrary summation
of some sequential portion of the output of reduce?  For example, a
sum of all of the hours between two dates / keys?  It's the same
reduction function except applied across multiple keys, it could be
annotated in the b-tree index the same way the reduction per key is
done now (or will be done).


If it isn't safe to use the reduce function as the combine function,
it could be explicit:

"views": {

             "all": "function (doc) {...snip...}",

             "count": {

                           "map": "function (doc){...snip...}"

                           "reduce": "function (tag, counts){...snip...}"

                           "combine": "function (counts){...snip...}"




It seems very powerful to me, if this functionality were available.


View raw message