'spring mongodb: arrayFilters is absent

I need to build an update operation like this:

db.collection.update({
  "referencedGeneralPractitioner.id": "id1"
},
{
  $set: {
    "referencedGeneralPractitioner.$[elem]": {
      "resourceType": "practitioner",
      "id": "id1",
      "field": "modified"
    }
  }
},
{
  "multi": true,
  "arrayFilters": [
    {
      "elem.id": {
        $eq: "id1"
      }
    }
  ]
})

I've tried to build it using spring data mongodb:

Query query = new Query();
Update update = new Update();
this.mongoTemplate.updateMulti(
    query.addCriteria(Criteria.where("referencedGeneralPractitioner.id").is(practitionerReference.getId())),
    update
        .set("referencedGeneralPractitioner.$[elem]", practitionerReference)
        .filterArray(Criteria.where("elem.id").is(practitionerReference.getId()))
    ,
    Patient.class
);

However, as you can see in the log it performs next update:

Calling update using query:

{
   "referencedGeneralPractitioner._id":"ae3e9046-5f78-434e-bf39-e6477a8183a9"
}

and, update:

{
   "$set":{
      "referencedGeneralPractitioner.$[elem]":{
         "_id":"ae3e9046-5f78-434e-bf39-e6477a8183a9",
         "resourceType":"practitioner",
         "field": "modified"
      }
   }
}

As you can see, arrayFilters block is not present.

Any ideas?



Solution 1:[1]

It should be

.filterArray(Criteria.where("elem").is(practitionerReference.getId()))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex Blex