Document not found exception thrown - while using collection.upsert

Hi CB Team,
Currently i am observing that when we perform collection.upsert operation and if document does not exist CB throw Document Not Found exception, basically it’s should create on if key is not found. Can someone help me to understand ? beside that where i find can full document of upsert/insert/replace …?

MutationResult upsert​(String id, Object content) Upserts a full document which might or might not exist yet.

Reference link : Collection (Couchbase Java SDK 3.2.5 API)

@mehul I recommend you check out the SDK documentation, it covers those semantics.

If you want to get a DocumentNotFound if the document does not exist, you need to use the replace operation.

Based on SDK document when use collection.upsert it’s should create document if document does not exist but currently it’s throwing document not found exception. I have shared the link in my previous note.

if you have any other link for that SDK document you can share …

@mehul I’m pretty sure that’s not the case. Upsert will insert if it doesn’t exist and replace it if it does. Do you have a piece of sample code you can share that demonstrates your issue?

Here is the code snippet
@Override
public MutationResult upsertDocument(String key, JsonObject doc) {
return collection.upsert(key, doc,UpsertOptions.upsertOptions().expiry(getInstant(doc)));
}

public Instant getInstant (JsonObject doc){
return Instant.ofEpochSecond(Integer.parseInt(String.valueOf(doc.get(“expiryTime”))));
}

Got an issue, thanks for helping

@mehul and what’s the exception including stack trace you are getting?

@mehul what was done to fix this issue