couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guy Moulton <>
Subject Counting unique items
Date Sat, 21 Nov 2009 21:09:01 GMT

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.


View raw message