If I have a simple collection such as:
Fruits:
Banana:
title: \"Banana\"
vitamins: [\"potassium\",\"B6\",\"C\"]
Apple:
title: \"Apple\"
vitam
There's no way to do multiple array-contains queries in Firestore. You can, however, combine as many where conditions as practically possible. Therefore, consider this:
[Fruits]
title: "Banana"
vitamins:
potassium: true
b6: true
c: true
Firestore.firestore().collection("Fruits").whereField("vitamins.potassium", isEqualTo: true).whereField("vitamins.b6", isEqualTo: true)
However, this still doesn't allow a clean OR search. To query for fruits with vitamin-x or vitamin-y, you'd have to get more creative. Furthermore, this approach should not be used if there are a lot of possible values and they need to be combined with compound queries. That's because Firestore does not permit more than 200 composite indices and each composite index would need to specify the exact vitamin. Which means you'd have to create an individual composite index for vitamins.b6, vitamins.potassium, etc. and you only have 200 total.