When filtering on a specific field of the objects within an array with $nin, I expect a document to match if no object in the array has that field matching the $nin. But currently, if any object within the array has that field not matching the $nin, the document is returned.
This behaviour differs from e.g. CosmosDb.
Example
@Test
void testMatchesNinFieldInArray() throws Exception {
Document query = json("{'tags.value': {$nin: ['B', 'C']}}");
assertThat(matcher.matches(json("tags: [{'value': 'A'}, {'value': 'D'}]"), query)).isTrue();
assertThat(matcher.matches(json("tags: [{'value': 'A'}, {'value': 'B'}]"), query)).isFalse();
assertThat(matcher.matches(json("tags: [{'value': 'A'}, {'value': 'C'}]"), query)).isFalse();
}
When filtering for documents where the tags array doesn't contain a tag with value B or C, I expect only the first document to be returend, but the second and third document are also returned because they contain {'value': 'A'} which matches $nin: [ 'B', 'C']