couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Dingwall <>
Subject Re: Eliminate keys during reduce?
Date Wed, 26 Feb 2014 16:42:30 GMT
Ingo Radatz wrote:
> Do you really want to eliminate keys? I would say you have to prevent the uninteresting
keys in the map step.
> If you want to filter uninteresting values you have to return a filtered version of the
"values"-object in the reduce step.
I don't know the that the result is not interesting until the reduce has 
been run so I can't filter during the emit.  Let's say I have a set of 
documents that emit:
[ a, v ] = 1
[ a, w ] = 1
[ a, x ] = 1
[ b, y ] = 1
[ b, z ] = 1

I understand that the result of the reduce for each unique key is stored 
in index but this value could be re-reduce(reduce([ a, {v, w} ]), 
reduce([ a, x])) and reduce([ b, {y,z} ]).

If the reduce function is a sum of the values when group_level=1 so it 
would give:
[ a ] = 3
[ b ] = 2

but I only want results in the set when the final value of the reduce is 
odd.  Even when I don't know if it is the final reduce call I can 
discard any intermediate points where the sum is even because even + odd 
= odd.  If I try to return null in the reduce/re-reduce when the value 
is even I get:

[ a ] = 3
[ b ] = null

I would like to have just but I don't know (or if) the keys can be 
entirely eliminated in the reduce step.

[ a ] = 3


View raw message