[DRIVERS-137] Project and sort by $meta. Created: 03/Feb/14  Updated: 15/Apr/19  Resolved: 22/Jun/16

Status: Closed
Project: Drivers
Component/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Barrie Segal
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on RUBY-723 Support $meta project and sort Closed
depends on CSHARP-820 Integrate text search into normal que... Closed
depends on PYTHON-632 Support list containing pair of (str,... Closed
Related
is related to NODE-132 Project and sort by $meta. Closed
Driver Compliance:
Key Status/Resolution FixVersion
PYTHON-632 Done 2.7
CSHARP-820 Done 1.9
RUBY-723 Done 1.10.0

 Description   

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.



 Comments   
Comment by Andrew Morrow (Inactive) [ 03/Mar/15 ]

Validating for C++11 because validated for C

Generated at Thu Feb 08 08:20:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.