products where each document has an array field tags, which query returns all documents where tags contains the string "organic"?db.products.find({tags: "organic"})In MongoDB, querying an array field with a value directly matches documents where the array contains that value. So {tags: "organic"} finds documents where tags includes "organic".
Other operators like $elemMatch, $in, and $all have different purposes and are not needed here.
orders where each document has an array items with subdocuments containing price, which query returns documents where at least one item has a price greater than 100?db.orders.find({"items.price": {$gt: 100}})Using "items.price": {$gt: 100} queries documents where any element in the items array has a price greater than 100.
Option D also works but is more verbose. Option D is invalid because items is an array, so matching a subdocument directly without $elemMatch or dot notation won't work. Option D is incorrect because $all expects exact matches.
scores contains a value less than 50?Option A is missing a colon between $lt and 50, causing a syntax error.
Options A, B, and C are valid MongoDB queries for this purpose.
users where the array roles contains the value "admin". Which query is the most efficient?Querying with {roles: "admin"} directly matches documents where the array contains "admin" and is the simplest and most efficient.
Using $elemMatch or $in adds unnecessary complexity and overhead.
events where each document has an array participants with subdocuments containing name and age. Which query returns documents where there is a participant named "Alice" who is exactly 30 years old?Option C uses $elemMatch to ensure both conditions apply to the same participant object.
Option C tries to match the entire array element exactly, which is unlikely to match unless the object is exactly {name: "Alice", age: 30} with no extra fields.
Option C matches documents where any participant has name "Alice" and any participant (not necessarily the same) has age 30, which is not guaranteed to be the same participant.
Option C requires the array to contain both objects separately, which is not the intended meaning.