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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.4.1
    • Fix Version/s: 2.4.3, 2.5.0
    • Component/s: Text Search
    • Labels:
      None
    • Operating System:
      ALL

      Description

      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||"

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: