I have a small CouchDB table with the following document structure:
{
"_id": "22e5cfffa3d363bb1dd3f2293e002953",
"idRubric": "9bf94452c27908f241ab559d2a0d46c5",
"category": "open",
"yada yada" : "for the rest of the fields"
}
There are 4 possible values of category and (currently) 41 possible values of idRubric. I'm attempting to create a view which allows me to select only those documents where idRubric and category simultaneously match a given value. My current map function looks like this:
{
"_id": "_design/views",
"_rev": "32-845188957d423477750fef0cd96f0b51",
"views": {
"byRubricCategory": {
"map": "function(doc) {if(doc.idRubric, doc.category){emit(doc.category, doc);} }"
}
}
}
The result of this is an array which shows all documents which contain the provided idRubric. If I swap out idRubric for category, then I get all documents matching the category. I've attempted specifying the result as [doc.idRubric, doc.category], however that just returns a null set.
I am not using the reduce function because (with my limited understanding) the objective of map appears to be to reduce the set to a single value, which I don't want, I need the result set which will, at a minimum, have 4 documents and may have 20-30.
I've already been through 20 or topics on CouchDB and this topic, but all appear to refer to multiple key queries where the focus is key1 OR key2. I'm trying to get to a logical AND rather than a logical OR. Thanks.
via Bob Dill
No comments:
Post a Comment