Complete the code to create a partial index on the 'status' field where status is 'active'.
db.users.createIndex({ status: 1 }, { partialFilterExpression: { status: [1] } })The partialFilterExpression requires the value to be a string, so we use "active" with quotes.
Complete the code to create a partial index on the 'age' field only for documents where age is greater than 18.
db.people.createIndex({ age: 1 }, { partialFilterExpression: { age: { [1]: 18 } } })The operator $gt means 'greater than', so it filters documents where age is greater than 18.
Fix the error in the partial index creation by completing the filter expression correctly.
db.orders.createIndex({ total: 1 }, { partialFilterExpression: { total: { [1]: 100 } } })The correct MongoDB operator for 'greater than or equal' is $gte with a dollar sign.
Fill both blanks to create a partial index on 'category' where category is either 'books' or 'magazines'.
db.library.createIndex({ category: 1 }, { partialFilterExpression: { category: { [1]: [[2]] } } })The $in operator filters documents where the field matches any value in the array. The array should contain "books" and "magazines".
Fill both blanks to create a partial index on 'score' where score is between 50 and 100 inclusive.
db.scores.createIndex({ score: 1 }, { partialFilterExpression: { score: { [1]: 50, [2]: 100 } } })Use $gte for 'greater than or equal to' 50, $lte for 'less than or equal to' 100.