I want to get bulk write metrics from Mongo server, like count of insertions, deletions, modifications, but the following methods always return 0.
BulkWriteResult.getInsertedCount()
BulkWriteResult.getMatchedCount()
BulkWriteResult.getDeletedCount()
BulkWriteResult.getModifiedCount()
this is my code snippet-
List<ReplaceOneModel<Document>> request = new ArrayList<>(Arrays.asList( new ReplaceOneModel<>(
new Document("_id", "133499"),
document,
new ReplaceOptions().upsert(true))));
BulkWriteResult writeResult = mongoCollection.bulkWrite(request);
writeResult.getInsertedCount(),
writeResult.getMatchedCount(),
writeResult.getDeletedCount(),
writeResult.getModifiedCount());
All bulk writes are executed successfully, but the counts of insertions, modifications, always return 0.
_idfield whose value is the string "133499". Is there such a document?upsertto true. Have you tried passing options to that constructor?upsertset to true, upserts are working fine, but insertedCount() always returning 0