Group level on Node.js

Hello,

I trying to make work the group_level in node.js but I always get this error:

{ [Error: REST error query_parse_error]
  code: 4104,
  reason: 'Multi-key fetchs for reduce view must include `group=true`' }

And as you can see in the call code (above) I'm using the flag group=true.

viewQuery.query( {keys:[ [appID, "1"], [appID, "2"], [appID, "3"] ], group:true, group_level:1, reduce:true}, function(err, results) 

Any idea why this is happening? With out the group_level works fine but just group by general level.

Thank you!
Jesus

Do you mind showing us the View code and some JSON document it will help to debug.

Can you execute the Query from the browser using the REST URL, if yes can you share with us the parameters that are working.

regards
Tug
@tgrall

1 Answer

« Back to question.

Hi,

Here's my view:

function (doc, meta) 
{
  if(doc.jsonType == "device" && doc.active == 1 && doc.disabled == 0)
  {
    emit([doc.app_id, doc.platform_id] , doc.last_open[0]);
  }
}

Also I have discovered that If I call the view using a range of keys the group level works, in this way:

viewQuery.query( {startkey:[1, 1], endkey:[1, 3], group_level:1, reduce:true}, function(err, results)
{
});

So I have needed remove the group tag and use just the group_level, but this doesn't work when the key is not a range and is an array of keys...

If I use the REST API I have the same error on the website:

http://serverAddress:8092/buckbetName/_design/desingName/_view/viewName?group=true&group_level=1&keys=%5B%5B1%2C1%5D%2C%5B1%2C2%5D%2C%5B1%2C3%5D%5D&reduce=true&connection_timeout=60000&limit=10&skip=0
 
{"error":"query_parse_error","reason":"Multi-key fetchs for reduce view must include `group=true`"}

Also please document that in the website...

Thanks,
Jesus