What is the best way to get documents after querying a view?

I’ve been pondering about this for a while now and have looked around on here and elsewhere for the answer but I am unable to find anything that answers a trivial question.

I’ve been developing in Clojure using the wonderful Couchbase-clj (https://github.com/otabat/couchbase-clj) library and a feature that seems to be missing is fetching the documents along with the views.

As demonstrated here: https://github.com/otabat/couchbase-clj/blob/master/test/couchbase_clj/test/query.clj#L16 - I can pass a parameter

(cbq/create-query {:include-docs true})

This will include the documents along with the view results and I can perform my tasks on the result.

There seems to be no equivalent of this in .net sdk’s - is that correct?

I am aware that the cost of hit and miss on couchbase is minimal… but there is always the network latency and such things to be considered and if I query a view that returned a 100 result keys I wouldn’t want to contact couchbase 100 times to display / process the documents.

Right now, I am getting around this problem by querying, collecting all keys, getting all documents with multiple keys

Client.Get(keys);

The trouble with this is, very rarely, after the view returns the keys, the documents are deleted before I fetch them… and the results from Client.Get() is not sorted in the order of the keys so I use my original keys to sort the resultant documents and this has a missing key and regardless of this fact it seems like a waste of round trip for me.

Is there a better way of doing this?

Apologies if I have missed something fundamental or it has been described somewhere already, the search on this forum seems to be a bit restrictive and google didn’t take me anywhere helpful.

Hello,

Your approach is correct, you can get the document using the ID or a list of ID. Note that it is probably better to use a single get by ID instead of a list to keep the sorting.

Also you can use the row.GetItem(); method.

As you noticed the includeDocs does not exist in the .Net client.

Regards
Tug
@tgrall