See Part 1 here.
Part 2: Index Handling
Now you have a good idea of what kind of indices you need for your class and how to define them. Next, how do you handle them?
Query Plan
(REMEMBER: Like any modifications to a class, adding indices in a live system has its risks – if users are accessing or updating data while an index is populated, they may encounter empty or incorrect query results, or even corrupt the indices that are being built.