Hi Sean,
and thank you so much for your reply.
On 06/06/11 22:09, Sean Copenhaver wrote:
Anyway, back to what you are trying to accomplish. Honestly it sounds like
you are trying to get too advanced for the built-in _count or _sum reduce
functions. Have you tried writing a custom reduce function that does the
grouping how you want, basically by name alone?
https://gist.github.com/1010318
I tried this out with 10 docs fitting your example structure and with a
plain query (no grouping, no filtering, reduce on) I get back:
{ John: 4, Jane: 6 }
Looks spot on! Thank you _so_ much for doing this.
I'm really curious how this performs, I will be-siege my couch with bulk
updates, giving it a big-ish data set while simultaneously be-siege it
with reads GETs querying this map/reduce you've created. Will be very
interesting.
I'm still puzzled, though. When reading up on reduces, I got put off
doing anything fancy in the reduce function as the guide on
http://guide.couchdb.org/draft/views.html#example/3 states:
"A common mistake new CouchDB users make is attempting to construct
complex aggregate values with a reduce function. Full reductions should
result in a scalar value, like 5, and not, for instance, a JSON hash
with a set of unique keys and the count of each."
And from my understanding, this is exactly what I want to do here, but
perhaps I'm misunderstanding the author's meaning here?
Cheers,
-Torstein