How to convert this custom update query to Java code

Hi @Shrey_Soni and welcome to community forum!!

Please use the below code snipped to use the $set operator:

Arrays.asList(new Document("$set", 
    new Document("recipientEmail", 
    new Document("$toLower", "$recipientEmail"))
            .append("senderEmail", 
    new Document("$toLower", "$senderEmail"))))

The following documentation on Update Many using Java might also be helpful in this case.

Please note that MongoDB Compass and Atlas provides with the feature to export the aggregation pipelines to language specific codes.
Please refer to the documentation for Export Pipeline to Specific Language in compass and Atlas for trying out.

Let us know if you have any further questions.

Regards
Aasawari

2 Likes