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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.5
    • Affects Version/s: 2.5.4
    • Component/s: Text Search
    • ALL
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      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 }
      

            Assignee:
            rassi J Rassi (Inactive)
            Reporter:
            tyler@10gen.com Tyler Brock (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: