Repro:
b.l.drop(); db.f.drop(); assert.commandWorked(db.l.insert([{a: [1]}, {a: {"00": 1}}])); assert.commandWorked(db.f.insert({b: 1})); const pipeline1 = [ {$lookup: {from: "f", localField: "a.00", foreignField: "b", as: "docs"}} ]; const pipeline2 = [ {$_internalInhibitOptimization: {}}, {$lookup: {from: "f", localField: "a.00", foreignField: "b", as: "docs"}} ]; // Uses SBE. jsTestLog(db.l.aggregate(pipeline1).toArray()); // Only {a: {"00": 1}} matches {b: 1} // Uses document source $lookup. jsTestLog(db.l.aggregate(pipeline2).toArray()); // Both local documents match {b: 1}
This is likely because SBE treats localField as a regular $match ($match treats "00"-type fields as field names, not indexes).
Classic $lookup treats "00"-type fields as both an index and a field name. I believe this is unintentional, and likely should be fixed.