Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumMongoDBtext and $regex searchSingle-choice MCQ

You define a text index with weights and run a `$text` query. You want results ordered by relevance. Which approach returns documents sorted from most to least relevant?

db.articles.find( { $text: { $search: "mongodb" } }, { score: { $meta: "textScore" } } ).sort({ score: { $meta: "textScore" } })