'Mongo db find multiple conditions on the same key

I encountered an unexpected behavior in find() logic on mongodb community 5.0.6.

My collection is:

{ _id: 1, a: 1, b: 1 }
{ _id: 2, a: 2, b: 2 }
{ _id: 3, a: 3, b: 3 }

when I execute

db.selection.find({a:1,b:2})

I obtain an empty set as resultset, as expected for condition a=1 AND b=2 (AND logic in selection)

But when I execute

db.selection.find({a:1,a:2})

Which should represent the logic condition a=1 AND a=2 I obtain this result

{ _id: 2, a: 2, b: 2 }

Honestly I was expecting an empty set again. Someone can explain it?



Sources

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

Source: Stack Overflow

Solution Source