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

Phrase search won't match phrases that aren't space-delimited

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.3, 2.5.0
    • Affects Version/s: 2.4.1
    • Component/s: Text Search
    • Labels:
      None
    • ALL

      The query parser generates the phrase list from the token stream, separating tokens with spaces. The phrase matcher performs a byte-by-byte comparison to determine a match (post-lowercasing). Thus, the only documents that will be returned in a phrase match are documents in which the phrase tokens are space-delimited.

      See, for example:

      > db.foo.ensureIndex({a:"text"},{default_language:"none"})
      > db.foo.find()
      { "_id" : ObjectId("515b316ed8714740e78cf351"), "a" : "foo-bar" }
      { "_id" : ObjectId("515b3170d8714740e78cf352"), "a" : "foo.bar" }
      { "_id" : ObjectId("515b3172d8714740e78cf353"), "a" : "foo+bar" }
      { "_id" : ObjectId("515b3174d8714740e78cf354"), "a" : "foo/bar" }
      { "_id" : ObjectId("515b31e3d8714740e78cf355"), "a" : "foo, bar" }
      { "_id" : ObjectId("515b31e5d8714740e78cf356"), "a" : "foo  bar" }
      > db.foo.runCommand("text",{search:'"foo-bar"'}).results.length
      0
      > db.foo.runCommand("text",{search:'"foo.bar"'}).results.length
      0
      > db.foo.runCommand("text",{search:'"foo+bar"'}).results.length
      0
      > db.foo.runCommand("text",{search:'"foo/bar"'}).results.length
      0
      > db.foo.runCommand("text",{search:'"foo, bar"'}).results.length
      0
      > db.foo.runCommand("text",{search:'"foo  bar"'}).results.length
      0
      > db.foo.runCommand("text",{search:'"foo bar"'}).results.length
      0
      

      All of the above searches yield queryDebugString "bar|foo||||foo bar||"

            Assignee:
            rassi J Rassi
            Reporter:
            rassi J Rassi
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: