-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
ALL
-
The documentation for queries states that,
Implicitly, a logical AND conjunction connects the clauses of a compound query so that the query selects the documents in the collection that match all the conditions.
Therefore, I expect this query with two $expr fields to find documents with an array where field foo is the same at indexes 0 and 1, and field bar is different:
db.collection.find({ $expr: { $eq: [ { $arrayElemAt: ['$arrO.foo', 0] }, { $arrayElemAt: ['$arrO.foo', 1] } ] }, $expr: { $ne: [ { $arrayElemAt: ['$arrO.bar', 0] }, { $arrayElemAt: ['$arrO.bar', 1] } ] } });
What happens is that other documents are returned as well, where foo is different between arrO[0] and arrO[1].
Collection:
[ { arrO: [ { foo: 1, bar: "bar diff..." }, { foo: 2, bar: "bar ...erent", } ] }, { arrO: [ { foo: 3, bar: "bar diff..." }, { foo: 3, bar: "bar ...erent" } ] } ]
- duplicates
-
SERVER-6439 Duplicate fields at the same level should not be allowed
- Backlog