Sync Gateway view and reduce possible?

Are reduce functions supported in the Sync Gateway?

Hey @paulbrand,

The reduce function is supported where you have your map and optional reduce logic within your project. For reference, the Understanding reduce functions goes into further details on implementation.

Ok, it seems to working in 1.0.4, but not with the latest code that’s on Github.
I have a simple view function (removed some checks):

function (doc, meta) {

and the reduce:


I upload that to the Sync gateway v1.0.4 using the REST API. I can then query the view with reduce using this URL:


With the latest release this does not work anymore, I do not get any response from the sync gateway.
Unfortunately I don’t have access to Sync Gateway log output at the moment.
Should this still work with the latest code in Git?

Hi @paulbrand,

Thanks for the info.
I’ve just tried running this map and reduce function with SG 1.0.4 and SG 1.1.
For reference, I used this:

  "views": {
    "by_creator": {
      "map": "function(doc, meta) {emit(doc.creator_id);}",
      "reduce": "_count"

With 1.0.4, the view query runs as expected. With 1.1, it doesn’t work (crash log). If I remove the reduce it does work. Can you confirm that it works for you with the map function only?

Changes were recently made to support view queries on the public port which returns the filtered view query result for the logged in user.


Yes, I can confirm that in 1.0.4 using the admin port I can query the view with and without the reduce function. With the latest Sync Gateway code using the reduce does not work anymore.

1 Like

Ok thanks I’ve opened a ticket


Thanks James :smile: