couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Metson <si...@cloudant.com>
Subject Re: couchdb teporaly average view
Date Fri, 29 Nov 2013 12:38:08 GMT
If you split your data out into a list like [year, month, day, hour, minute] and used that
as the key for the map you’d be able to query with different group levels to get averages
at different granularities.  


On Friday, 29 November 2013 at 10:58, Robert Newson wrote:

> map:
>  
> emit(doc.created, doc.value);
>  
> reduce:
>  
> _stats
>  
> then query with startkey and endkey appropriately. This will give you
> the sum of all values between the two keys and the number of rows.
> Divide one by the other to derive mean average. This will work for
> startkey/endkey's that span hours, days or weeks.
>  
> B.
>  
>  
> On 28 November 2013 20:22, Gerardo Di Iorio <arete74@gmail.com (mailto:arete74@gmail.com)>
wrote:
> > Sorry for previous post
> > Hi,
> > i try to use couchdb for store data sensor.
> > My document is
> > {
> > "_id": "a631c192ffebb7b0d543863925f4e8f9",
> > "_rev": "1-9e8bacc2a3b79a2dc37ffeb5c53383f9",
> > "source": "sensorbox",
> > "location": "living room",
> > "type": "temperature",
> > "value": 25.3,
> > "created": 1358270795751
> > }
> > I now have need to create an view for
> > 1)average temp every hour
> > 2)average temp every day
> > 3)average temp every week
> >  
> > Is possible "recall" in avg_day the data of view avg_hour ??
> > If yes can send me an example?
> >  
> > Regards
> > Gerardo Di Iorio
> >  
> >  
> >  
> >  
> > 2013/11/28 Gerardo Di Iorio <arete74@gmail.com (mailto:arete74@gmail.com)>
> >  
> > > Hi,
> > > i try to use couchdb for store data sensor.
> > > My document is
> > >  
> > > {
> > > "id":"123"
> > > "source": "
> >  
>  




Mime
View raw message