• Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.6, 4.1.1
    • Component/s: Internal Code
    • Labels:
      None
    • ALL
    • Hide

      {{db.articles.insert([

      { _id: 1, subject: "one", author: "abc", views: 50 }

      ,

      { _id: 2, subject: "lastone", author: "abc", views: 5 }

      ,

      { _id: 3, subject: "firstone", author: "abc", views: 90 }

      ,

      { _id: 4, subject: "everyone", author: "abc", views: 100 }

      ,

      { _id: 5, subject: "allone", author: "efg", views: 100 }

      ,

      { _id: 6, subject: "noone", author: "efg", views: 100 }

      ,

      { _id: 7, subject: "nothing", author: "abc", views: 100 }

      ])}}

      {{}}{{db.articles.createIndex(

      {subject: "text", author: "text"}

      )}}{{}}

      }}{{db.articles.count({$text: {$search: "\"one\"")}}{{}}

      }}{{db.articles.count({$text: {$search: "\"one\" \"abc\""}}{{}}

      {{}}

      Show
      {{db.articles.insert([ { _id: 1, subject: "one", author: "abc", views: 50 } , { _id: 2, subject: "lastone", author: "abc", views: 5 } , { _id: 3, subject: "firstone", author: "abc", views: 90 } , { _id: 4, subject: "everyone", author: "abc", views: 100 } , { _id: 5, subject: "allone", author: "efg", views: 100 } , { _id: 6, subject: "noone", author: "efg", views: 100 } , { _id: 7, subject: "nothing", author: "abc", views: 100 } ])}} {{}}{{db.articles.createIndex( {subject: "text", author: "text"} )}}{{}} }}{{db.articles.count({$text: {$search: "\"one\"" )}}{{}} }}{{db.articles.count({$text: {$search: "\"one\" \"abc\"" }}{{}} {{}}

      I had created a collection in mongo db as show below

      {{db.articles.insert([

      { _id: 1, subject: "one", author: "abc", views: 50 }

      ,

      { _id: 2, subject: "lastone", author: "abc", views: 5 }

      ,

      { _id: 3, subject: "firstone", author: "abc", views: 90 }

      ,

      { _id: 4, subject: "everyone", author: "abc", views: 100 }

      ,

      { _id: 5, subject: "allone", author: "efg", views: 100 }

      ,

      { _id: 6, subject: "noone", author: "efg", views: 100 }

      ,

      { _id: 7, subject: "nothing", author: "abc", views: 100 }

      ])}}

      after that I given text indexing to the field subject and author.

      {{db.articles.createIndex(

      {subject: "text", author: "text"}

      )}}

      Now I am trying to search a word with "one" in indexed field. When I execute query ...

      db.articles.count({$text: {$search: "\"one\"")}}

      ... the result is 1.

      The problem is that when I want combination of words "one", "abc" ...

      db.articles.count({$text: {$search: "\"one\" \"abc\""}}

      ... it gives the result as 4. Including the records that contains the subject name as "lastone", "firstone", "everyone", "one" as the result.

      So my question is that why the first query dosn't fetch 4 records

            Assignee:
            nick.brewer Nick Brewer
            Reporter:
            sameesh096 Sameesh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: