[JAVA-2491] Clarify "upserted items" in javadoc for BulkWriteResult.getUpserts() Created: 13/Apr/17  Updated: 10/Jun/23

Status: Backlog
Project: Java Driver
Component/s: Documentation
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Mark Helmstetter Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: roadmap
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Quarter: FY24Q2
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

The javadoc for BulkWriteResult.getUpserts() says
> Gets an unmodifiable list of *upserted* items, or the empty list if there were none.

Arguably, "upserted items" is a bit ambiguous as a user might expect that to be populated when there's an update. The mongo shell documentation for https://docs.mongodb.com/manual/reference/method/BulkWriteResult/#BulkWriteResult.upserted is a little more specific, as it states:
> An array of documents that contains information for each document *inserted* through operations with the Bulk.find.upsert() option.



 Comments   
Comment by Jeffrey Yemin [ 10/Jun/23 ]

Just FYI, the server's update command does not include the list of updated _id values (nor the list of deleted _id values for the delete command.
I don't know the history behind that decision, but I suspect it's because the list is essentially unbounded so there are performance implications of maintaining the list on the server and returning it to the client. I also think that for most multi updates and deletes, the application doesn't need the list, and we wouldn't want to make all users pay the cost of it. But regardless, there would be no way for the Java driver to do this without a corresponding change on the server.

Comment by Almog Tavor [ 16/Sep/22 ]

I agree with Sam. That's not what the user would want/expect. And if so, where would a user be able to find the updated ids?

Comment by Sam Peretz [ 12/Jan/18 ]

Why doesn't BulkWriteResult include both updated ids as well as inserted ids? It should have getUpdated() that returns the former and getInserted() that returns the latter. Or, at the very least, getUpserted() should return both updated and inserted ids.

Generated at Thu Feb 08 08:57:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.