> db.monty.find()
{ "_id" : 1, "a" : "What… is the air-speed velocity of an unladen swallow?" }
{ "_id" : 2, "a" : "What do you mean? An African or a European swallow?" }
{ "_id" : 3, "a" : "Huh? I… I don’t know that." }
{ "_id" : 45, "a" : "You’re using coconuts!" }
{ "_id" : 55, "a" : "What? A swallow carrying a coconut?" }
> db.monty.ensureIndex({a: "text"})
WriteResult({ "nInserted" : 1 })
> db.monty.find({$text: {$search: "swallow coconut"}})
{ "_id" : 2, "a" : "What do you mean? An African or a European swallow?" }
{ "_id" : 55, "a" : "What? A swallow carrying a coconut?" }
{ "_id" : 45, "a" : "You’re using coconuts!" }
{ "_id" : 1, "a" : "What… is the air-speed velocity of an unladen swallow?" }
> db.monty.find({$text: {$search: "swallow coconut"}}, {textScore: {$meta: "textScore"}}).sort({textScore: {$meta: "textScore"}})
{ "_id" : 55, "a" : "What? A swallow carrying a coconut?", "textScore" : 1.3333333333333333 }
{ "_id" : 45, "a" : "You’re using coconuts!", "textScore" : 0.6666666666666666 }
{ "_id" : 2, "a" : "What do you mean? An African or a European swallow?", "textScore" : 0.625 }
{ "_id" : 1, "a" : "What… is the air-speed velocity of an unladen swallow?", "textScore" : 0.5833333333333334 }
>