incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kowsik <kow...@gmail.com>
Subject Reducing to unique values...
Date Fri, 27 Feb 2009 22:13:38 GMT
First time I'm playing with rereduce and stumped a bit. I got emits like this:

    ("a", "one")
    ("a", "two")
    ("a", "one")
    ("a", "one")
    ("b", "three")
    ("b", "three")

What I would like to get at the end of the reduce is this:

    { key: "a", value: [ "one", "two" ] }
    { key: "b", value: [ "three" ] }

I could implement a really simple reduce like this:

    reduce(k, v) { return v }

and then unique on the client side.

Other option is to emit(["a", "one"], 1), reduce to sum and then use
startkey/endkey to walk through the unique keys.

Is there a better way?

Thanks,

K.

Mime
View raw message