incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wout Mertens <wout.mert...@gmail.com>
Subject Re: how to count the number of unique values
Date Sun, 17 Oct 2010 15:40:03 GMT
On Oct 16, 2010, at 17:04 , Anand Chitipothu wrote:

> 2010/10/15 Wout Mertens <wout.mertens@gmail.com>:
>> Just wanted to add that if you have a map function that emits (tag, 1) for each tag
and then a reduce function that's just _count, you will have everything you need for painting
a tag cloud.
>> 
>> The view with group=true will list all tags exactly once, with their count. CouchDB
doesn't tell you how many rows are in the result so you'll have to count them yourself.
>> 
>> So you load that entire view in memory and you can draw the tags with their relative
sizes.
>> 
>> Wout.
> 
> The example I gave is a rather simplified example. I'm working a data
> containing 25M+ docs with books, works and subjects. I need to find
> the list/count of works for each subject. I don't think it is
> practical to load the view into memory to compute the required result.
> 
> Anand

Right, in that case you should use either the method that was posted earlier by Randall Leeds,
in which the reduce function counts the unique keys given to it (and keeps track of the first
and last keys to avoid double counting), or use the multi-view code from http://github.com/normanb/couchdb

Wout.
Mime
View raw message