- 
    Type:
New Feature
 - 
    Resolution: Done
 - 
    Priority:
Major - P3
 - 
    None
 - 
    Component/s: None
 
MongoDB 2.6 includes a $text query operator. There's a new projection syntax for including each result's relevance in the output. There's also a new syntax for sorting by relevance descending:
> db.test.createIndex({s: 'text'})
> db.test.insert({s: 'spam'})
> db.test.insert({s: 'spam eggs and spam'})
> db.test.insert({s: 'sausage and eggs'})
>
> db.test.find(
...   // query
...   {$text: {$search: 'spam'}},
...   // new projection syntax
...   {_id: false, s: true, score: {$meta: 'textScore'}}
... ).sort(
...   // new sort syntax
...  {score: {$meta: 'textScore'}}
)
{ "s" : "spam eggs and spam", "score" : 1.25 }
{ "s" : "spam", "score" : 1.1 }
Drivers probably already support the new projection syntax, since it's a similar structure to the $elemMatch projection operator.
If a driver has been validating that the value portion of a sort specifier is 1, -1, or a string, it should now also allow a subdocument as the value, possibly with $-prefixed field names.
- depends on
 - 
                    
RUBY-723 Support $meta project and sort
-         
 - Closed
 
 -         
 - 
                    
CSHARP-820 Integrate text search into normal query system
-         
 - Closed
 
 -         
 - 
                    
PYTHON-632 Support list containing pair of (str, dict) in sort
-         
 - Closed
 
 -         
 
- is related to
 - 
                    
NODE-132 Project and sort by $meta.
-         
 - Closed
 
 -         
 
- links to