I am very new Couchabse and I have been reading the docs even though it is well written but I guess I lack some basic knowledge / context about Couchbase document design in general so the docs were very hard for me to understand.
So I have two types of documents blog / comment as below and I am trying to project the view into something like view1 below.
The blog / comment may not be appropriate example for this type of design but I am basically mimicking has many / belong to relationship as found in the doc relating-documents-for-retrieval. I am stuck on how to achieve view1, is it the job of view or is it the job of SDK or is it the combination of view and SDK?
I was reading about couchdb since couchbase is based on it. There’s a Linked_documents using include_docs=true but I can’t find anything in couchbase. I think this is what I need to achieve what I am trying to do. Does couchbase support linked documents at all?
Using Couchbase you cannot get any linked document in a view/query. The Map/Reduce receives only the current document as parameter (doc) and cannot access other document.
So if you want to get linked document you have to do a lookup using the key, so you retrieve the document using the view, and then do a client.get(“id”);
You can also do some interesting queries using collated views, but it is not what you need in your case:
The feature you are referring from CouchDB does not exist inside Couchbase. Couchbase applications are usually not using the include_docs parameters that returns the doc but retrieve the document using a get operation (done automatically in the Java SDK). The get is really fast since it is based on memcached.
You mentioned that Map/Reduce receives only the current doc hence I need to use client.get(“id”) to access other documents. In case I need to access multiple documents I guess client.getBulk() would be my best option and this eliminates multiple trips to the Couchbase. Am I correct?
I am still reading about collated views so I don’t have any comments at this stage.
I don’t really understand your last paragraph would you be able to elaborate.
“Couchbase applications are usually not using the include_docs parameters that returns the doc but retrieve the document using a get operation (done automatically in the Java SDK). The get is really fast since it is based on memcached.”