The statement from author is right. The _id is not a compound index, it's a mere exact index.
The high voted answer is misleading and talking about the right things without matching the original question
_id: {
entityAId
entityBId
}
to be able to query entityAId , or query and sort on entityAid and entityBid,
you ll need to create a compound index at _id.entityAid and _id.entityBid