Can you do range scan on document id?
I deleted my previous question because it seemed to be too obvious to ask since the default admin page was doing exactly what I wanted; paged range scan on document id with sort order.
But how do you do this?
I looked up the Java API doc, but couldn't find a way to do it.
(The admin page for beer-sample doesn't even have a view.)
Thanks in advance.
haebin, the index used within the UI (_all_docs) would actually not be recommended by us since it is not the most performant nor efficient way.
I think you'll want to start with this page: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-sampl....
That describes how to create a primary index off of the document name, and then a basic example on how to query it by range.
From there, you can use the Java view/query interface: http://www.couchbase.com/docs/couchbase-sdk-java-1.1/api-reference-view....
You *can* use skip, but we would actually recommend using "limit" as described here: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writi....
(note that you may want to read "up" and "down" into the different sections of the manual for more context/information)
Let us know if that helps.
Perry
Thank u for the reply.
We designed our data model to work around the limitation.
No view, just some doc id convention to meet our needs.
(i.e. groupid_1, groupid_2, ... for parallel paged bulk read and groupid-someid key for specific relation)
Since view relies on disk we thought it wouldnt b as fast as the model above.
Hello haebin. That is certainly a valid approach, and you are right that it is going to be faster and more scalable. For certain use cases it's not possible to use just the doc id's and so the views will be the second option.
With the above model, the size of memory required was too big since the model was using document id heavily.
Also, the model needed separated memory space for paged list. (and more complicated management logics at app level)
So, we had to choose Redis over Couchbase since it supported SortedSet. http://redis.io/commands#sorted_set
This SortedSet data structure met our needs perfectly.
Even though Couchbase is far better in fault tolerance, replication and auto sharding support, its server supported data structure was too limited for our use.
Thank you for your support!
By looking at the query via Chrome profiler, the view name seems to be "_all_docs".
Also, it must be using skip as described in http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writi....
hmm...