What index types should I know?
Understand the concept
MongoDB offers different index types because equality lookup, array search, text search, uniqueness and expiry have different needs. A compound index orders several fields together, while a partial index includes only documents matching a condition. TTL indexes support eventual cleanup rather than precise scheduling.
Important ideas
-
Single-field: one field; compound: multiple fields; multikey: array values.
-
Unique: prevents duplicate indexed values; partial: indexes only matching documents.
-
Text: word search; TTL: expires documents asynchronously, not at an exact second.
-
A unique index has specific behavior for missing/null fields and arrays, so test it against the actual optional-field model.
Can you explain it without the notes?
What index types should I know?
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
MongoDB offers different index types because equality lookup, array search, text search, uniqueness and expiry have different needs. A compound index orders several fields together, while a partial index includes only documents matching a condition. TTL indexes support eventual cleanup rather than precise scheduling.
Turn this concept into a clear answer.
- Choose an index from a query or data rule; do not add every index type just because it exists.
Adapted from 04_MONGODB_MONGOOSE.md · “What index types should I know?”. Examples are study fragments; framework behavior can depend on your version.