Cosmos DB で全削除する

// Azure Cosmos DB Libraries for Java // https://docs.microsoft.com/ja-jp/java/api/overview/azure/cosmosdb?view=azure-java-stable FeedOptions queryOptions = new FeedOptions(); queryOptions.setEnableCrossPartitionQuery(true); String host = "yourhost"; // Get key from Azure Web Console // read write key String key = "yourkey"; DocumentClient client = new DocumentClient("https://" // + host // + ".documents.azure.com:443", key, // new ConnectionPolicy(), ConsistencyLevel.Session); String collectionLink = String.format("/dbs/%s/colls/%s", DATABASE_ID, COLLECTION_ID); // 適当に指定する String q = "SELECT * FROM container1"; // 全文書 List<Document> results = client // .queryDocuments(collectionLink, q, queryOptions).getQueryIterable().toList(); for (Document doc : results) { System.err.println(doc); String documentLink = doc.getSelfLink(); RequestOptions options = new RequestOptions(); // check your configuration of cosmos db container String partitionKey = ((org.json.JSONObject) doc.get("item")).getString("xxx"); options.setPartitionKey(new PartitionKey(partitionKey)); client.deleteDocument(documentLink, options); System.err.println("deleted: " + documentLink); } client.close();