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

Forbid $meta sort on field that does not have $meta project

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.5.4
    • Fix Version/s: 2.5.5
    • Component/s: Text Search
    • Labels:
    • Operating System:
      ALL

      Description

      In the spec it says:

      Examples of sorts disallowed by the grammar:
      {“x.y”: {$meta: “text”}}

      Examples invalid queries with a $meta sort (where a corresponding $meta projection is not correctly specified):
      db.collection.find({$text: {$search: “hello”}, {t: {$meta: “text”}}).sort({s: {$meta: “text”}})

      Yet this appears to work (and sort using the text metadata):

      > db.test.find(
          { $text: {$search: "tyler" }},
          {s: {$meta: "text"}}).sort({"WRONG.\^$.$$$": {$meta: "text"}}
      )
      { "words" : "tyler brock", "cool" : true, "s" : 0.75 }
      { "words" : "tyler brock awesome cool", "s" : 0.625 }
      { "words" : "tyler brock cool cool", "s" : 0.625 }

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: