couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carl Bourne <carl.bou...@me.com>
Subject Re: Help with reduce function
Date Sat, 06 Oct 2012 19:29:06 GMT
Aurelian,

Thanks for the reply. 

I need the ability to query by date. I don't quite understand what you mean by your last comment
with regards date. Please could you elaborate?

Best regards,

Carl

On 6 Oct 2012, at 20:01, Aurélien Bénel <aurelien.benel@utt.fr> wrote:

> Hi Carl,
> 
> Try always to do more with your index. This is indeed where the power of Map/Reduce lies.
> 
> map:
> function(o) {
>   emit([o.date, o.country], null);
> }
> 
> reduce:
> _count
> 
> Then query it with group=true.
> 
> 
> Regards,
> 
> Aurélien
> 
> P.S. If you did put "date" after "country", and if date were written as an array, you
could choose the time slot at query time (year or month, day, hour, etc.) by changing the
"group_level".  

Mime
View raw message