Can a View emit a JSON doc with the .net client?
I am new to couchbase and have been reading the documentation and testing with a .net project. I am trying to call a simple View that will return an array of documents with a certain type. The View return all of the IDs along with the document key/values in a dictionary array. Is it possible to return just the plain JSON string of the document instead of the dictionary of key/value pairs. This seems like it should be simple so maybe I am just missing something?
Also, I have tried calling the Get(key) after the GetView but this results in two calls to couchbase. I am trying to do it all in one call to the View.
As discussed in other thread, you should "never" emit the full document. The index are stored on disk and by emitting the full document you will just "double the size" of your DB for nothing.
In addition the indexes are using the OS disk cache that is not as efficient for Couchbase than the built it memcached.
About your comment on "hitting 2 times the database" this is NOT an issue. The get(id) is so fast that you should not have any issue. (the document will be in the cache.). I do agree that it is big change in the mindset compare with what we do sometimes in RDBMS based application.
So Emit only what you need and get the document when you need it using the get operation.
You can create a view that returns doc (i.e. use emit(doc.id, doc)). But it's bad idea because in this way your view indexing will be slow and it will consume large amount of disk size. It's better to emit(doc.id, null) and then with second query get all needed key's values via multiget. So don't try to do that in one call.