Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

Do Design Document Views Filter Each Other?

1 reply [Last post]
  • Login or register to post comments
Thu, 01/10/2013 - 16:31
pgrigor
Offline
Joined: 01/08/2013
Groups: None

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.

Top
  • Login or register to post comments
Fri, 01/11/2013 - 07:46
tgrall
Offline
Joined: 09/05/2012
Groups: None

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

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker