You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "Kevin R. Coombes" <ke...@gmail.com> on 2012/06/01 23:11:04 UTC
map-reduce question
Hi,
I have a database with documents that each include two categorical and
one continuous value. Something like
{
fruit: "apple",
size: "small",
quality: 1.7
},
{
fruit: "banana",
size: "large",
quality: 3.6
}
I'd like to be able to compute responses to views/queries that basically
ask:
how many documents do I have (broken down by 'fruit' and 'size')
that have the 'quality' greater than some cutoff?
And I'm having trouble identifying the appropriate couch map/reduce view
to implement this. If I emit keys of the form
[doc.quality, doc.fruit, doc.size]
then I can do the quality-based searches using
http://couch/db/_design/whatever/_view/quality?startkey=[2]
but the default "_count" kinds of reduce functions will split things up
by quality, which I only care about for the filtering aspects.
How do I write the reduce function to skip the top level?
Kevin