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

Create compatible text-search query syntax

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

      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)

            Assignee:
            hari.khalsa@10gen.com hari.khalsa@10gen.com
            Reporter:
            paul.pedersen Paul Pedersen
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: