Map Reduce view - returning data in couchbase but not returning data in python

I created a couchbase map reduce view, published it to production & tested the view, it returns me 4 rows. The view has only map part as below:
Couchbase View

function(doc) {
	if (doc.t == "memGroupsTest") {
		if (doc.memGroupMems) {
			for (i=0; i < doc.memGroupMems.length; i++) {
				if (doc.memGroupMems[i].requestSentTs == 0) {
					emit(doc.memId, doc.groupId, doc.groupName, doc.memGroupMems[i].groupMemId, doc.memGroupMems[i].allowTrainNotifications);

The following is the Python code

from couchbase.views.params import Query
			#cb is my bucket object
			rows = self.cb.query("_design/dev_myDev", "pending", include_docs=False)
			for row in rows:
		except Exception as e:

The following message gets printed on console:

<RC=0x3B[HTTP Operation failed. Inspect status code for details], HTTP Request failed. Examine 'objextra' for full result, Results=1, C Source=(src/http.c,144), OBJ=ViewResult<rc=0x3B[HTTP Operation failed. Inspect status code for details], value=None, http_status=400, tracing_context=0, tracing_output=None>, Tracing Output={":nokey:0": null}>

I had also tried the following…still getting zero rows.

from couchbase.views.params import Query
			q = Query()
			q.limit = 10
			rows = self.cb.query("_design/dev_myDev", "pending", include_docs=False, query=q)

The same view is returning data when queried in couchbase, but zero rows when queried in python.
Am I missing something???

Thanks ,


Could you try running: cbc view _design/dev_myDev pending and see if that works? This exercises libcouchbase directly.

The emit call in your View code sends more arguments than are normally accepted (2), although as this works through the server UI, this doesn’t appear to be the reason for the difference in behaviour.



1 Like

Update: spotted the problem:

You shouldn’t prefix the ddoc name with the namespace (i.e. “_design”) - it should just be:
rows = self.cb.query(“dev_myDev”, …)

Hope that helps,


1 Like