Take a look at this video (it's in JavaScript, but it exactly solves your problem): https://youtu.be/sKFLI5FOOHs?t=612
Basically, you need to structure your data for your queries. In OP example Question will have field like category_level: "cat_1"
. Then you can perform query equalTo("cat_1")
. You can leave out both category
and level
fields if you need it for other queries (but you will need to handle duplication in that case).
If you know that your number of items is small, simplest solution is to just pull all category=cat
and filter level=1
items.