First up you need to specify how your reduce function works in a rereduce case (http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views has info). On Cloudant the rereduce is always called (to collect data from the various shards into the final view result). That's why you get the response you see.
Second, it looks like you're trying to get a count of data by primary_key. In general you want to use the built in _sum
function for that - it's faster than custom js code, and _sum
works over objects in Cloudant.
Third, the unreduced view will contain the doc._id automatically, so emit a 1 instead to make the _sum
work.