Pagination / Filter


#1

Look at:
http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writi
Couchbase 2.0 just came out. It supports indexing.
I believe 1.8 you couldn’t do what you wanted, but now you can.


#2

Hi jabberfest
Thanks for your fast reply. I have seen that page, but unfortunately, I haven’t been able to implement this in the java client (I use the CouchbaseClient). Can you advice? What about views?
And, what about the ordering/sorting? If I store a serialized object, will I be able to sort by an attribute within that object? Do I have to add a POJO?
Thanks!
Best,
Sullivan


#3

Hello everyone
I’m fairly new in in-memory caching systems and I’m building a little e-commerce-page where I would love to use Couchbase - it seems very great to me.
I have one question and haven’t been able to find a question so far:
Let’s say, I persist 1000 “sullivan-Product”-objects into Couchbase (either Couchbase Buckets or Memcache) and I want them to display on my page (I work with Grails).
How am I able to get the first 10 objects, sorted by their price descending. (I know it’s not the same approach as a MySQL database) - but how do you do that with a memory cache?
Your feedback is appreciated!
Best,
Sullivan


#4

I’m using the Couchbase model gem for Ruby on Rails. Not sure about your setup.
That shouldn’t matter though. You need to create a view with a map function similar to below. I think this should create an index on the document price only for your “sullivan_products” in a given bucket.
They key is the product price and you can then pass in the options to sort by the key. It varies depending on which ORM you are using, but the idea should be the same.
function(doc, meta)
{
if (doc.type = “sullivan_product”)
{
emit(doc.price, null);
}
}
*I also recommend reading the Couchbase 2.0 manual from start to finish. It saves you tons of time in the end. I dedicated a day to read it all.