Do Design Document Views Filter Each Other?
Thu, 01/10/2013 - 16:31
I have two views in a single design document. Each view emits the same document type filtered by different criteria. The criteria sometimes overlap.
Let's say the two views are by_phone and by_email on the "member" design document.
When I do a query of the by_phone view I *only* see members who have both phone and email fields, and vice-versa for by_email queries.
However, if I make a new design document "member2" and have only the by_phone view I see *all* the members with phone fields.
Is this the proper behavior? If so it's not at all clear from the documentation.
Hello, Pgrigor,
When developing your map function you need to be sure you test the existence of the attributes you are using in it. If you do not test the existence, an error is raised and the indexing of is stopped on this document.
This is documented in the "View Writing Best Practice"
http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writi...
in the "Check Document Fields" section.
In you case this mean you should do
View 1
if (doc.phone && doc.email) { // you logic to emit }View 2
if (doc.phone ) { // you logic to emit }Let me know if this is working.
Regards
Tug
@tgrall