Delete documents that don't have PK in Azure Cosmos DB (Java SDK)

To delete a document that has a PK set as a value

options.setPartitionKey(new PartitionKey(pkValue));
client.deleteDocument(doc.getSelfLink(), options);

However, for documents for which PK is not set

options.setPartitionKey(null);
client.deleteDocument(doc.getSelfLink(), options);

Or

client.deleteDocument(doc.getSelfLink(), null);

Why when I try to delete it like

PartitionKey value must be supplied for this operation.

Error is returned.

To avoid this

// com.microsoft.azure.documentdb.Undefined
options.setPartitionKey(new PartitionKey(Undefined.Value()));

It seems that it is a specification that must be done. The same is true not only in Java but also in other languages.

(Since the value doesn't exist in the first place, I'd like it to be passed as null.)

Recommended Posts

Delete documents that don't have PK in Azure Cosmos DB (Java SDK)
Delete All from Java SDK in Azure Cosmos DB
Upsert from Java SDK to Azure Cosmos DB
Select * from Java SDK to Azure Cosmos DB
Update if the document already exists in Azure Cosmos DB Java SDK, create new if it does not exist
Azure functions in java
Append text to BlobItem in Azure BlobStorage SDK Java V8
Create Azure Functions in Java