I've read that for only OR queries like:
find($or [{field1:a}, {field2:b}])
an index for each field shall be created (simple or compound with the fields as prefix). For AND queries like:
find(field1:a, field2:b)
a compound index shall be created to cover it throughly. But what to do when a query has AND's and OR's together?
find($or[field1:a, field2:b], field3:c, field4:d)
What are all of the indexes to be created in this case?
MongoDB 4.4.6
TL;DR: You probably do not need a compound index here but rather individual field indexes on the highest cardinality, most performance-demanding queries.
Compound indexes are very useful when your AND pattern is predictably hierarchical. If a compound index is created on fields A,B,C then a query on A will be fast, A,B will be fast, and A,B,C will be (really) fast. Query on just B cannot use the index, nor B,C, nor C.
If you run your query with explain(true) and examine the output, you will see that multiple indexes can be used for both $or and $and types of queries.