I have data in mongodb something like this. There is a collection of cats. Cats are sorted into different categories and ranked from 1 to 100. One cat can be in 2 or more categories. There are 1000 categories.
COLLECTION : "cats"
KEYS
rank.category1 = 1; // ranked 1st in category
Question : If I want to do find () to return all the "cats" that have a "rank" in category 2, where $ exists => "rank.category2", what is the correct way to index this? Can I just put a simple ascending index into the "rank" collection or do I need an index for all 1000+ categories * of keys? Is there a better way to store this information or an easier way to index it?
source share