In Couchbase Server 3.0, the documents in my bucket are of the form:
{ "id":"xyz", "categories":["news", "articles", "etc.etc.."]}
I want to write a view such that when I specify key="news", all the documents that include "news" in the "categories" array attribute will be returned.
I went as far as writing a map function that emits the same article as many times as we have elements in "categories" array.
function (doc, meta) {
for(var i = 0; i < doc.categories.length ; i++)
emit(doc.categories[i], doc);
}
But I'm stuck with the reduce.