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

Create compatible text-search query syntax

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Text Search
    • Labels:
      None

      Description

      Text search integration

      1. Syntax

      // basic search

      db.coll.find( {$text : {$search : "term"}} )

      // language option

      db.coll.find( {$text : {$search : "term", $language : "spanish" }} )

      // integrated skip / limit

      db.coll.find( {$text : {$search : "term"}} ).skip(10*(pageno-1)).limit(10)

      // integrated sort

      db.coll.find( {$text : {$search : "term"}} ).sort(

      { date : 1 }

      )

      // integrated projection

      db.coll.find( {$text : {$search : "term"}},

      {description : 1, _id : 0}

      )

      // integrated filter (explicit and)

      db.coll.find( {$and : [ {$text : {$search : "term" }},

      {name : /a.*/}

      ] } )

      // integrated filter (implicit and) GOOD-ERH

      db.coll.find( { $text : {$search : "term" }, name : /a.*/ } )

      // all features combined

      db.coll.find( { $and :

      [

      {$text : {$search : "\"phrase terms\" \"and term\" -term",

      $language : "spanish" }},

      { name : /a.*/ }

      // filter

      ]

      },

      { name : 1, description : 1, _id : 0 }

      // projection

      ).sort(

      { date : 1 }

      ).skip(10).limit(10)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: