When using $ne on a field of an object in an array, only documents where none of the array objects match should be returned. Currently, as long as 1 of the objects matches the $ne expression, then the document is returned.
Test case to reproduce:
@Test
void testMatchesNeFieldInArray() throws Exception {
Document query = json("'tags.value': {$ne: 'B'}");
Document document = json("_id: 1, tags: [{'value': 'A'}, {'value': 'D'}]");
assertThat(matcher.matches(document, query)).isTrue();
document = json("_id: 1, tags: [{'value': 'A'}, {'value': 'B'}]");
assertThat(matcher.matches(document, query)).isFalse();
}
The second assertion returns true as it matches one of the fields, but it should return false.