Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-137

Project and sort by $meta.

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • $i18n.getText("admin.common.words.hide")
      Key Status/Resolution FixVersion
      PYTHON-632 Done 2.7
      CSHARP-820 Done 1.9
      RUBY-723 Done 1.10.0
      $i18n.getText("admin.common.words.show")
      #scriptField, #scriptField *{ border: 1px solid black; } #scriptField{ border-collapse: collapse; } #scriptField td { text-align: center; /* Center-align text in table cells */ } #scriptField td.key { text-align: left; /* Left-align text in the Key column */ } #scriptField a { text-decoration: none; /* Remove underlines from links */ border: none; /* Remove border from links */ } /* Add green background color to cells with FixVersion */ #scriptField td.hasFixVersion { background-color: #00FF00; /* Green color code */ } /* Center-align the first row headers */ #scriptField th { text-align: center; } 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.

      Attachments

        Activity

          People

            barrie Barrie Segal
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: