Complete the code to create a compound index on fields 'name' and 'age'.
db.users.createIndex({ name: 1, [1]: 1 })The compound index is created on 'name' and 'age'. The order matters for query optimization.
Complete the code to find documents where 'name' is 'Alice' and 'age' is 30 using the compound index.
db.users.find({ name: 'Alice', [1]: 30 })The query filters on 'name' and 'age' fields, matching the compound index fields.
Fix the error in the compound index creation by choosing the correct field order.
db.users.createIndex({ [1]: 1, name: 1 })The correct order is 'age' then 'name' if the index is intended that way; here, 'age' must be the first field.
Fill both blanks to create a compound index on 'city' ascending and 'score' descending.
db.players.createIndex({ [1]: 1, [2]: -1 })The index is on 'city' ascending (1) and 'score' descending (-1).
Fill all three blanks to create a compound index on 'category' ascending, 'price' ascending, and 'rating' descending.
db.products.createIndex({ [1]: 1, [2]: 1, [3]: -1 })The compound index includes 'category' and 'price' ascending, and 'rating' descending.