com.couchbase.client.java.AsyncBucket.get(String id)
Retrieves a JsonDocument by its unique ID. If the document is found, a JsonDocument is returned. If the document is not found, the Observable completes without an item emitted
A simple way would be to chain in the “singleOrDefault()” operator with something like “singleOrDefault(null)”. You can then check in your onNext call if the document is null (then it’s not found) and if it’s non null it was found.
Note that, from a global Rx perspective, there is also the alternative of using defaultIfEmpty which is a little bit simpler (allows the original to emit n items, whereas singleOrDefault additionally checks that no more than one item is ever emitted).
But in our case we only ever expect the get to return one document, so singleOrDefault is the best match.