incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jarrod Roberson <>
Subject Re: Is there anyway to specify a group_level of "id"?
Date Mon, 19 Apr 2010 16:27:59 GMT
On Mon, Apr 19, 2010 at 10:10 AM, Adam Kocoloski <> wrote:
> On Apr 18, 2010, at 1:37 AM, Jarrod Roberson wrote:
> Hi Jarrod, I'd need a little more detail or an example before I could whether what you
want to do is possible.  Best,
> Adam

I am working on what I think is a clever solution to not being able to
do variable "select where" sql like selections on CouchDB.

here is my map function

  emit(['cnnid', doc.cnnid], null);
  emit(['guid', doc.guid], null);
  emit(['src', doc.sourceServer], null);
  emit(['dest', doc.destServer], null);

running a reduce that works with group_level=1 it is merging lists of
_ids by field. what the result is a unique list of _ids that match
each field name when run with keys=[['cnnid',"11111111"],["src","a"]].
I get output that groups by cnnid and src what I want to do is
rereduce just the "final" output one more time to reduce the keys down
to the unique list of _ids from the resulting groups.

curl -X POST -d '{"keys":[["cnnid","82534864"],["src","a"]]}'
looks like this


I tried group_level=0 but that does the same thing as 1 in my case. I
tried hacking at the Erlang source to get it to run a another final
rereduce with a "special" group_level=9999 but I didn't have any luck
getting that to work. What I finally resorted to is a List function
that does the final reduce/merge of the _ids (same thing the reduce
function is doing really) but I really think it would be clever if I
could get the reduce to run one last rereduce instead of the List
function solution.

Here is a post about it in more detail

View raw message