incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: Counting unique items
Date Sun, 22 Nov 2009 02:00:23 GMT

On 21 Nov 2009, at 22:09, Guy Moulton wrote:

> Hello,
> 
> I'm trying to get a count of the number of unique items in a database.
> Documents look like this:
> 
> Item: Item_A, User: Dave
> Item: Item_A, User: John
> Item: Item_A, User: Jane
> Item: Item_B, User: John
> Item: Item_B, User: Anne
> 
> In the above example, I'd like to know that there are 2 items.  So
> far, I have a map/reduce that produces one view row for each kind of
> item (similar to the example on the wiki) :
> 
> key: "Item_A", value:"Null"
> key: "Item_B", value:"Null"
> 
> So the number I need is the number of rows in the view.
> 
> According to the wiki, if I pass limit=0, it should give me the
> meta-data, but this doesn't seem to work on views that have a reduce
> function.  I don't want to count rows in the client as there could
> potentially be a very large number.
> 
> Any ideas would be very much appreciated.

Hi Guy,

this might help you: http://books.couchdb.org/relax/reference/views-for-sql-jockeys#Get%20Unique%20Values%20(SELECT%20DISTINCT%20field%20FROM%20table)

Cheers
Jan
--


Mime
View raw message