I am developing a couchapp. I have documents that contains a field called tags, and I am trying to retrieve the unique tags among all the docs. My map/reduce function is as follows:
map.js
function(doc){
if(doc.tags){
emit(doc.tags,1);
}
}
reduce.js
function(keys,values,rereduce){
return sum(values);
}
And the output returned is the count of all the tags. Where am I going wrong?