Unable to get data in Query view via Users Port


#1

I have created a new View via Admin REST API and i am able to see data only in Admin port (4985). When i query the view via Users Port (4984), i am getting total rows as 0.

SG Version: 1.3.1
Couchbase Server Version: 3.03

Note: I have custom Map and reduce function for the view

Below is the response i get.

{“total_rows”:0,“rows”:null,“Collator”:{}}

Below is the response i get when running on Admin port.

{
“total_rows”:2,
“rows”:[
{“id”:"",“key”:“catalog1”,“value”:{“Soap”:1,“Toothbrush”:1}},
{“id”:"",“key”:“catalog2”,“value”:{“Soap”:1}}
],
“Collator”:{}
}

My Sync Gateway config.json

{
“log”: [“CRUD”, “REST+”, “Access”],
“databases”: {
“sk”: {
“unsupported”: {
“user_views”: {
“enabled”: true
},
“oidc_test_provider”: {
“enabled”: false
}
},
“users”: {
“GUEST”: {
“disabled”: false, “admin_channels”: [" * “]
}
},
“CORS”: {
“Origin”: [”"],
“LoginOrigin”: ["
"],
“Headers”: [“Content-Type”],
“MaxAge”: 1782000
},
“server”: “http://localhost:8091”,
“bucket”: “default”,
“sync”: “function(doc) { if(doc.catalogs) { for(var i = 0; i < doc.catalogs.length; i++) { channel(doc.catalogs[i]); } } }”
}
}
}

I have tried restarting the sync-gateway also. still not getting right data.
Need some help on getting data while querying view via user port.


#2

@mahesth

Are you using the GUEST account to query the view on the public REST API?


#3

Yes. For now, I am using GUEST account to query the view.


#4

I have tried querying the view via user port as normal user (not GUEST). Still i get the same empty response


#5

Just a reminder to the issue.
@andy
Any changes needs to be done in the config to overcome this issue ??


#6

To verify channel access - is the user able to retrieve the docs you’re expecting to see in the view results using a direct GET over the REST API?


#7

Actually - I see now that you mention you’ve got a reduce function defined for your custom view. Reduce isn’t currently supported for views queried through the public API, as Sync Gateway isn’t able to apply the appropriate channel filtering on the response.

Some details in the conversation on this ticket: