Trying to use SubDoc mutations upsert command via java SDK

Hi Im running couchabse server 7.1.3 docker container and trying to use the 3.3.4 couchbase java sdk version.

The issue i am facing is, when i use the collection.mutateIn() method to perform a sub document mutation using the upsert command, i am expecting to get the result of the operation as a MutateInResult object. when i try to use the MutateInResult.contentAs(0, String.class) to see the response i get the “Index 0 is invalid” error. i see that the operation as in is successful in the DB, i can see the desired json path has the updated value.

P.S: i only have a single mutation to perform which is the upsert command.

can someone please help if i am missing something here

Hi @chand770,

MutateInResult.contentAs is useful only for getting the result of a MutateInSpec.increment or decrement operation.

If you get a MutateInResult, you can be confident the mutation was applied successfully.

Thanks,
David