You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Brad King <br...@gmail.com> on 2008/07/17 23:44:30 UTC
views with reduce functions
I have a view with a simple reduce function to count some attributes
in the doc. It runs fine in Futon, but when I call it directly, it
doesn't return any results. I've checked my spelling like 8 times, and
other views I have are working just fine. Am I missing something
obvious?
{
"count": {
"map": "function(doc) {\n
if(doc.entityobject.Attributes.Manufacturer != \"\")\n
emit(doc.entityobject.Attributes.Manufacturer, 1);\n}",
"reduce": "function(keys, values) { \n return sum(values); \n}"
}
}
In Futon this returns a bunch of manufacturer count data as expected.
I then call from this URL
http://myserver:5984/inventorytest/_view/manufacturers/count
and it returns
{"rows":[{"key":null,"value":7740}]}
Re: views with reduce functions
Posted by Brad King <br...@gmail.com>.
Nevermind. Figured out I needed group=true.
On Thu, Jul 17, 2008 at 5:44 PM, Brad King <br...@gmail.com> wrote:
> I have a view with a simple reduce function to count some attributes
> in the doc. It runs fine in Futon, but when I call it directly, it
> doesn't return any results. I've checked my spelling like 8 times, and
> other views I have are working just fine. Am I missing something
> obvious?
>
> {
> "count": {
> "map": "function(doc) {\n
> if(doc.entityobject.Attributes.Manufacturer != \"\")\n
> emit(doc.entityobject.Attributes.Manufacturer, 1);\n}",
> "reduce": "function(keys, values) { \n return sum(values); \n}"
> }
> }
>
> In Futon this returns a bunch of manufacturer count data as expected.
> I then call from this URL
>
> http://myserver:5984/inventorytest/_view/manufacturers/count
>
> and it returns
>
> {"rows":[{"key":null,"value":7740}]}
>