MongoDB & NoSQL (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is a Multikey Index in MongoDB?
junior LevelMost AskedDatabases & SQL
In Simple Words:
When you index a field that contains an Array (e.g. tags: ["cloud", "k8s", "docker"]):
- MongoDB automatically creates a Multikey Index.
- It creates a separate index entry for every single element in the array.
- Queries like
db.articles.find({ tags: "k8s" })leverage the index directly. - Limitation: A compound index cannot have more than one array field (prevents Cartesian index explosion).