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

total_rows in view results and start/endkey usage

No replies
  • Login or register to post comments
Wed, 03/28/2012 - 02:52
ARabus
Offline
Joined: 09/30/2011
Groups: None

Hi all,

I got a minor problem with the result of a view when using start/end-key filtering.

The result is a json where the "total_rows" value is always the maximum number of documents the view could return, and not the "expected" number of the documents which match the given filter criteria.

Which gives me some headache when using a pagination.

My Workaround for now is using a view with a reduce function using only "_count" and using two queries:

  • first with reduce=false and the limit/skip values for paging
  • second with reduce=true

and then hacking the result set of the first query and changing the total_rows value to the result of the second query.
Which is a bad thing because there are two queries to Couchbase and the need to write to a (read-only) result set.

The two queries will look like similar to those:

  • /assets/_design/title/_view/sorted_by_rank?skip=0&limit=25&startkey=["foo","bar"]&endkey=["foo","bar",[]]&reduce=false
  • /assets/_design/title/_view/sorted_by_rank?startkey=["foo","bar"]&endkey=["foo","bar",[]]&reduce=true

Is there a way to get the number of matching document in the view result, that is regarding to startkey/endkey/keys but not limit/skip, w.g. in a key "matching_rows" or similar?

Best regards,

ARabus

Top
  • 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