mapreduce - How can I query by document attribute when the attribute is an array? -
in couchbase server 3.0, documents in bucket of form:
{ "id":"xyz", "categories":["news", "articles", "etc.etc.."]}
i want write view such when specify key="news", documents include "news" in "categories" array attribute returned.
i went far writing map function emits same article many times have elements in "categories" array.
function (doc, meta) { for(var = 0; < doc.categories.length ; i++) emit(doc.categories[i], doc); }
but i'm stuck reduce.
turns out map function sufficient, needed query key="cateogoryname" in url.
i confused because if don't wrap key in quotes in query mysterious error, see: https://issues.couchbase.com/browse/mb-7555
not sure if reduce function more efficient though..
Comments
Post a Comment