Complete the code to create an index on the 'name' field in MongoDB.
db.collection.createIndex({ name: [1] })In MongoDB, creating an index on a field uses 1 for ascending order.
Complete the query to find documents where 'age' is greater than 30 using an index.
db.collection.find({ age: { [1]: 30 } })The operator $gt means 'greater than' in MongoDB queries.
Fix the error in the index creation code to ensure it creates a compound index on 'age' ascending and 'score' descending.
db.collection.createIndex({ age: [1], score: [2] })Compound indexes use 1 for ascending and -1 for descending order.
Fill both blanks to write a query that uses an index to find documents where 'status' is 'active' and 'points' are at least 50.
db.collection.find({ status: [1], points: { [2]: 50 } })The status must be 'active' (a string) and points greater than or equal to 50 uses $gte.
Fill all three blanks to create a text index on 'title' and 'description' fields and then query documents matching 'mongodb'.
db.collection.createIndex({ [1]: "text", [2]: "text" })
db.collection.find({ $text: { $search: [3] } })Text indexes are created on fields like 'title' and 'description'. The search term must be a string like "mongodb".