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

view filtering

3 replies [Last post]
  • Login or register to post comments
Sun, 03/17/2013 - 03:18
retto
Offline
Joined: 12/23/2012
Groups: None

Hi,

I have a key in view like [int, string] and I need filter by two ways:
1) only by first part of key, in this case I put to startkey = [value, "\u0000"] and put to endkey = [value, "\u0fff"]. works correct and fine.
2) only by second part of key, in this case I need to filter like previous one point but vise versa . startkey = ["\u0000",value] and put to endkey = ["\u0fff",value]. But always no data after apply filter like this.
Can I filter view only by second part of key and ignore first part?

thanks.

Top
  • Login or register to post comments
Sun, 03/17/2013 - 03:32
joakimw
Offline
Joined: 09/13/2011
Groups: None

No, you can't filter on the second part only.

Indexes must be sorted somehow, and they are sorted by the first element first, then the second.
So a search on the second part would have to traverse the whole list of keys to find your matches. Couchbase doesn't do this (some other DB's do this, it's called a "key scan" and is really slow).

You have to create a second index using [string, int] instead and search on that.

Top
  • Login or register to post comments
Sun, 03/17/2013 - 03:35
retto
Offline
Joined: 12/23/2012
Groups: None

joakimw, very thanks.

Top
  • Login or register to post comments
Mon, 03/18/2013 - 00:22
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello,

In addition to Joachim answer let me point you to some interesting blog post about keys and ordering:
- http://blog.couchbase.com/understanding-letter-ordering-view-queries
- http://blog.couchbase.com/understanding-grouplevel-view-queries-compound...

It is not a direct answer to your question but it is interesting to have these pointer in this discussion.

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