Well I was wrong, a reduce query doesn't show the amount of rows. So you'll have to count the number of rows that the view Paul gave returns in your application, or you'll have to wait until CouchDB gains multiple map+reduce passes.

Wout.

On Apr 28, 2009, at 11:22 AM, Wout Mertens wrote:

You can cheat: simply get the MR view that Paul gave you with
group=true and it will tell you the total number of results, which is
the answer you're looking for. At least, I think so, I can't test now.

If it doesn't, this is yet another case for multi-MR views :)

Wout.

On Tuesday, April 28, 2009, Kevin Wang <[email protected]> wrote:
Sorry I think I made a mistake stating the problem.

I have the following 4 docs:

{"name": "foo", "prop": "value1"}
{"name": "bar", "prop": "value2"}
{"name": "foo", "prop": "value3"}
{"name": "bob", "prop": "value4"}

How to write the map/reduce functions so that I can get a view which returns the total number of unique name's? In this case, the result should be 3.

-- Kevin

On Mon, Apr 27, 2009 at 7:32 PM, Kevin Wang <[email protected]> wrote:

Hi All,

While I am trying to switch my mind to map/reduce model while accessing couchdb data, I found myself struggling. Here is a simple question that you
guys might be able to answer:

If I have the following set of data in a doc:

{"name": "foo", "prop": "value1"}
{"name": "bar", "prop": "value2"}
{"name": "foo", "prop": "value3"}
{"name": "bob", "prop": "value4"}

How to write the map/reduce functions so that I can get a view which
returns the total number of unique name's? In this case, the result should
be 3.

Thanks!

-- Kevin



Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to