You would need to either start with unique user id's or reduce this data twice (not sure if couchbase let's you create essentially a "subview" or not)
But basically you'd need to reduce this data to have only 1 row per user/color combination (grouping level of 2 with a key of [user, color]) and then reduce it again with a simple built in reducer _count using the color as the key. --chad On Fri, Dec 27, 2013 at 11:05 AM, Thomas <[email protected]> wrote: > Hi, > I was googling around for a solution of a map/reduce where I will be able > to perform a distinct/unique count of user ids, but I wasn't able to find a > concrete solution/answer to this topic. My case is to count the unique > users per day for example as well as other criteria. > I have for example the following JSON documents of events: > {"user":"user1", "color":"blue"} > {"user":"user1", "color":"blue"} > {"user":"user1", "color":"red"} > {"user":"user2", "color":"blue"} > And with my map/reduce view I want to do the following > * number of distinct users per color > { color: blue, count: 2} > { color: red, count: 1} > in SQL terms > select color, count(distinct user) as users from test group by color > Thanks > -- > You received this message because you are subscribed to the Google Groups > "Couchbase" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Couchbase" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
