incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcello Nuccio <marcello.nuc...@gmail.com>
Subject Re: Complex queries & results
Date Tue, 07 Jun 2011 06:50:20 GMT
2011/6/7 Torstein Krause Johansen <torsteinkrausework@gmail.com>:
> 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?

In my experience it is not a problem for a reduce function to return an hash.

The strict requirement for reduce functions, is to actually reduce the
data it get passed to a small constant size value, be it a scalar or
an object.

You can look at this example for an idea of what I mean
http://stackoverflow.com/questions/5637412/getting-a-list-of-documents-with-a-maximum-field-value-from-couchdb-view/5654154#5654154

I hope to be corrected if I am wrong.

Marcello

Mime
View raw message