According to this issue: MongoDB compound indexes on array fields
compound index with more than one array field is not allowed.
So let's suppose that the array field is contained. The elements can only come from the enum: ["A", "B", "C"]
. And the elements must be unique.
Hence, can I turn this field into an embedded document like so:
{
field_1: {
A: boolean
B: boolean
C: boolean
},
field_2: {
X: boolean
Y: boolean
Z: boolean
},
}
and then:
db.collection_name.createIndex(
{"field_1.A": 1}, {"field_1.B": 1}, {"field_1.C": 1},
{"field_2.X": 1}, {"field_2.Y": 1}, {"field_2.Z": 1}
)