Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-12193

Forbid queries with a $meta project and a non-$meta sort on same field

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.5.5
    • 2.5.4
    • Querying, Text Search
    • None

    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.

      Attachments

        Activity

          People

            rassi J Rassi
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: