I have a map function and reduce function to count all the occurrences of a key. The code is below for CouchDB 2.0 design document:
Map Function
function(doc) { emit(doc.domainID, 1); }
Reduce Function
_sum
Here is a snapshot of what the browser shows:
And here is the result when I run the following code in Python:
import couchdb
couch = couchdb.Server("http://localhost:5984/")
counts = couch['event_db'].view('doc/eventbydomainid',
reduce=True, descending=True)
Terminal result when printing key and value
I am expecting the following result, but not seeing it:
{"ad1": 32, "ad2": 1}
Any help would be appreciated.
Thank you,
Brian