Challenge - 5 Problems
Atlas Search Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Find documents matching a text phrase using Atlas Search
Given a collection named
books with an Atlas Search index on the title field, what is the output of this query?MongoDB
db.books.aggregate([
{
$search: {
text: {
query: "adventure",
path: "title"
}
}
},
{ $project: { title: 1, _id: 0 } }
])Attempts:
2 left
💡 Hint
Think about which titles contain the word 'adventure'.
✗ Incorrect
The $search stage with text operator finds documents where the 'title' field contains the word 'adventure'. Only titles with that word appear in the result.
🧠 Conceptual
intermediate1:30remaining
Understanding Atlas Search index types
Which of the following best describes the purpose of an Atlas Search index in MongoDB?
Attempts:
2 left
💡 Hint
Atlas Search uses a popular open-source search engine technology.
✗ Incorrect
Atlas Search indexes use Apache Lucene to provide fast and rich full-text search capabilities on MongoDB collections.
📝 Syntax
advanced2:00remaining
Identify the syntax error in this Atlas Search query
What error does this query raise?
MongoDB
db.products.aggregate([
{
$search: {
text: {
query: "smartphone",
path: ["name", "description"]
}
}
}
])Attempts:
2 left
💡 Hint
Check the Atlas Search documentation for the 'text' operator's 'path' field type.
✗ Incorrect
The 'path' field in the text operator can accept either a string or an array of strings to search multiple fields.
❓ optimization
advanced2:30remaining
Improve performance of an Atlas Search query filtering by category
You want to find documents with 'laptop' in the 'title' and category 'electronics'. Which query is more efficient?
Attempts:
2 left
💡 Hint
Atlas Search compound operator can combine multiple conditions efficiently.
✗ Incorrect
Using the compound operator inside $search allows filtering and text search in one stage, improving performance.
🔧 Debug
expert3:00remaining
Why does this Atlas Search query return no results?
Given this query, why might it return an empty result set?
MongoDB
db.orders.aggregate([
{
$search: {
text: {
query: "urgent",
path: "status"
}
}
}
])Attempts:
2 left
💡 Hint
Check if the field you search is indexed by Atlas Search.
✗ Incorrect
Atlas Search only searches fields included in its index. If 'status' is not indexed, no documents match.