updateMany while doing type change in mongoDB using Java

I have a use case to update data in a collection of mongoDB having avg size of 250kb.
Use case: convert datatype from String to Long for a field version.

I would like to do it in efficient way . Looking for options from Java and also through direct mongo queries.

MongoQuery found:

db.collection.updateMany({version : {$type: "string"}}, {$set: {version: {$toLong: "$version"}}})

Trying something like this below in java and not finding the version.

Bson filter = new Document("version", new Document("$type", "string"));
Bson newValue = new Document("version", *****);
Bson updateOperationDocument = new Document("$set", newValue);
collection.updateMany(filter, updateOperationDocument);

How to achieve this, not finding the right way.