Complete the code to create a sparse index on the field "email".
db.users.createIndex({ email: 1 }, { [1]: true })The sparse option creates an index that only includes documents where the indexed field exists.
Complete the code to find documents where the "phone" field exists using the sparse index.
db.contacts.find({ [1]: { $exists: true } })To use the sparse index on the phone field, query documents where phone exists.
Fix the error in the code to create a sparse index on "username".
db.accounts.createIndex({ username: 1 }, { [1]: true })The sparse option must be a boolean true, not a string.
Fill both blanks to create an index on "profile.age" and make it run in the background.
db.users.createIndex({ [1]: 1 }, { [2]: true })Use profile.age as the field and background: true to create the index without blocking operations.
Fill all three blanks to create a sparse, unique index on "email" with background creation.
db.customers.createIndex({ [1]: 1 }, { [2]: true, [3]: true, [4]: true })This creates an index on email that is both unique and sparse, running in the background.