During pipeline optimization, we currently rewrite a $or with equality conditions on the same path into a $in. That is:
There is also support to rewrite part of a $or as follows:
The first part of the optimization (replacing an entire $or with an $in) is supported by the new optimizer in the logical rewrites phase. The second part is not yet supported by the new optimizer. Eventually, when we don't run pipeline optimization before we hit the new optimizer, we'll need to support this behavior in the new optimizer.