On Wed, Dec 31, 2008 at 5:48 PM, Scott Robertson <[email protected]> wrote: > 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? >
No, not at the moment. The way the group_level is implemented you'd basically need to fold over the view twice or make that work.
