Include docs in view result rows - Java SDK v 3

On Java SDK 2 I used

ViewQuery.includeDocs(true)

and then I could get the document directly from the result rows.

Switching to SDK 3 I can’t find this option on the ViewOptions and the value of the ViewRow is always empty.
Is this option removed? Couldn’t find anything about it in the migration guide.

Hi Malin,

The “include docs” feature was not carried forward from SDK 2 to SDK 3. See How to get row.document() with java SDK 3.x - #7 by david.nault

You’re right, this is missing from the migration guide. I’ve filed DOC-8384 to track the issue.

Thanks,
David

Thank you David for your response!

This confirms to me Im not completely crazy :slight_smile:
I solved it by fetching the document by the id.
(still a little confused about why the value property is there at all - is there a case when it is not empty? maybe if you emit the document from the view?)

(still a little confused about why the value property is there at all - is there a case when it is not empty? maybe if you emit the document from the view?)

The row value comes from the second argument to the emit function (which can be null). See Map Function | Couchbase Docs

Emitting the entire document as the value is not recommended; see Views Best Practices | Couchbase Docs

Thanks,
David

1 Like