MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Modify multiple matching array values

I tried to modify array values with following :

        final UpdateResult ur = operations.updateMulti(
                new Query().addCriteria(
                        Criteria.where("tags.applications").in(Collections.singletonList(4))),
                new Update().set(String.format("%s.$","tags.applications"), 8),
                "testMetaModel");

the problem is, if the array is like tag: application: [1,2,3,4,4,5,6] If I use above “$” update, it could only update the first matched “4”, but I want to update all “4” to “8”, what should I do ? I use spring MongoTemplate.