couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Robertson" <sc...@zeepmobile.com>
Subject group_level and intermediate reduce results
Date Wed, 31 Dec 2008 22:48:23 GMT
I think I understand how group_level works. Is there a way to get the
results of multiple levels with one get?

For example say I'm creating a view that counts how many documents a
member has created and how many docs all the members of each group has
created. Using a two part key.

My map would look something like this

function(doc){
  emit([doc.group, doc.member], 1);
}

And my reduce sums the values

function(keys, values){
  return sum(values);
}

I can get the counts for each member like this
http://localhost:5984/mydb/_view/sums/all?group_level=2

Which return something like

key                             |  value
==================================
[group1,member1]     |  5
[group1,member2]     |  3
[group1,member3]     |  1
[group2,member4]     |  1

And  I can get the sums for each group
http://localhost:5984/mydb/_view/sums/all?group_level=1

key                             |  value
==================================
[group1]                     |  9
[group2]                     |  1

Is there away that I can request those values merged, so that it looks
like this?

key                             |  value
==================================
[group1]                     |  9
[group1,member1]     |  5
[group1,member2]     |  3
[group1,member3]     |  1
[group2]                     |  1
[group2,member4]     |  1

W/o having to make two separate requests?

Mime
View raw message