couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Metson <simonmet...@googlemail.com>
Subject Re: Grouping a view on a key not provided in the request
Date Sun, 22 Jan 2012 20:49:07 GMT
Hi, 
What about emitting the client id at the start of that list? Then you can just see entries
for that client. Also, you can change the group level to get views to aggregate further up
e.g. aggregate at the month or year instead of day level:

 startkey=[61, 2011,11,1]&endkey=[61, 2011,11,30]&group=true&group_level=3stale=ok

Would give you back (assuming you put the client id at the start of the list) something like:

[61, 2009, 11] => 44 ( 14 + 30 + ...)
[64, 2009, 11] = 30

etc. 

FWIW Mike Miller has quite a nice description/discussion of this on http://nosqltapes.com/video/understanding-mapreduce-with-mike-miller
if you have a spare hour (or you can skip 30 mins in to the bit on grouping reduces).
HTH
Simon


On Friday, 20 January 2012 at 08:11, Thomas Boniface wrote:

> Unfortunately I don't manage to create a view that would contain the
> expected result with the right format. The closest I could do was
> producing a result as follow:
> [2009, 11, 19, 61] => 14
> [2009, 11, 20, 61] => 30
> [2009, 11, 20, 64] => 30
> ...
> This represents 14 occurences for the client 61 on the 2009-11-19, 30 on
> the 2009-11-20 and so on. What I would like to retrieve is a resulted
> grouped on client id to avoid having multiple rows for the same client
> id)
> The view is called with
> startkey=[2011,11,1]&endkey=[2011,11,30,{}]&group=true&stale=ok



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message