[SERVER-12193] Forbid queries with a $meta project and a non-$meta sort on same field Created: 23/Dec/13  Updated: 07/Feb/14  Resolved: 21/Jan/14

Status: Closed
Project: Core Server
Component/s: Querying, Text Search
Affects Version/s: 2.5.4
Fix Version/s: 2.5.5

Type: Improvement Priority: Major - P3
Reporter: J Rassi Assignee: J Rassi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Forbid queries such as:

db.collection.find({$text:{$search:"hello"}},{s:{$meta:"textScore"}}).sort({s:-1})

  • This will help users figure out more quickly that they have to use sort({s:{$meta:"textScore"}}), not sort({s:-1}).
  • There is no support currently for these queries on a sharded collection (current behavior: mongod will sort on the value of the field in the document, but mongos will merge sort on the projected score field).
  • The analogous aggregation pipeline will in fact work as intended – by design, it can "correctly" sort on the computed field "s". Forbidding these queries in the query engine will avoid defining conflicting behavior for the two query systems.


 Comments   
Comment by Githook User [ 21/Jan/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-12038 SERVER-12193 LiteParsedQuery validate queries with $meta

Comment by Githook User [ 14/Jan/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: Revert "SERVER-12038 SERVER-12193 LiteParsedQuery validate queries with $meta"

This reverts commit 192f4bcd1b9a91cad4f184ad7cd3679b56cb9f5f.
Branch: master
https://github.com/mongodb/mongo/commit/9154de8aea7424d0b26b92d1b09d0164caee7c66

Comment by Githook User [ 13/Jan/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-12038 SERVER-12193 PlanCacheTest should use $meta properly

It is no longer valid to use a $meta sort without a $meta projection.
Update PlanCacheTest suite accordingly.
Branch: master
https://github.com/mongodb/mongo/commit/4f9c0008b9c046690d9d84579ccd98b8553412ab

Comment by Githook User [ 13/Jan/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-12038 SERVER-12193 LiteParsedQuery validate queries with $meta

Generated at Thu Feb 08 03:27:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.