couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kropp, Henning" <hkr...@microlution.de>
Subject Re: Multiple map reduce stages
Date Thu, 20 May 2010 12:25:39 GMT
Am 20.05.2010 12:25, schrieb Simon Metson:
> Hi,
>
>> I came up with the following solution. Grouping by value (uri) and time
>> using the group_level=1 and the start and end key like follow:
>>
>> /_temp_view?group=true&group_level=1&startkey=[1270826004.0]&endkey=[{},1270826011.0]
>>
>>
>> and simply counting
>>
>> function(doc) { emit([doc.URI,doc.Time], 1 );
>
> Shouldn't your start/end key also include the doc's URI? That way
> you'd only get the URI you are interested in for the date range that
> you specify. e.g. &startkey=[document1,
> 1270826004.0]&endkey=[document1,1270826011.0]. If you switch the view
> around to emit [doc.Time, doc.URI] as the key you can find all URI's
> in the time range using &startkey=[1270826004.0,
> 0]&endkey=[1270826011.0, {}].
> Cheers
> Simon

That should work, but if I change the order of URI and Time in the key I
am unable to group the result by URI using the group_level 1. And using
group_level 2 would result in grouping URIs with the same URI *and*
Time. Unfortunately there seems to be no way to tell exact what part of
the key to use for grouping, if I am not mistaken. Therefor I have
thought about a second map stage.

Thank you!

Mime
View raw message