couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ramanadham, Radhika" <radhika.ramanad...@emc.com>
Subject RE: running views return nothing with couchdb1.5.1
Date Thu, 22 May 2014 13:39:39 GMT
I am not sure how that would help as _stats doesn’t return average. Or is there a way to
get the average?


-----Original Message-----
From: Manokaran K [mailto:manokaran@gmail.com] 
Sent: Wednesday, May 21, 2014 9:22 PM
To: user@couchdb.apache.org
Subject: Re: running views return nothing with couchdb1.5.1

On Thu, May 22, 2014 at 6:27 AM, Ramanadham, Radhika <radhika.ramanadham@emc.com> wrote:
> Hi  Mike,
>
> Do, for one of the views, I need to return an average.
>
> So, my reduce function had -
>
> "cpu": {
>                 "map": "function(doc) { if ((doc.type == 'performance_stats'))  emit(doc.test_id,
doc.CPU) }",
>                 "reduce": "function(keys, values) "
>                           "{ "
>                 "avg = Math.round(sum(values)/values.length);"
>                                "return(avg)"
>                           " }"
>
> Now, if I want to use stats, which give me sum and count, I tried this, but doesn't 
work. What am I doing wrong?
>
> "cpu": {
>                 "map": "function(doc) { if ((doc.type == 'performance_stats'))  emit(doc.test_id,
doc.CPU) }",
>                 "reduce": "function(keys, values) "
>                           "{ "
>                 "avg = Math.round(_sum/_count);"
>                                "return(avg)"
>                           " }"
> -Radhika
>

Try this:

"reduce": "_stats"

Cheers,
mano

Mime
View raw message