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

Case sensitive text queries do not match terms with embedded NUL characters

    • Query
    • ALL
    • Hide
      load('jstests/libs/fts.js'); // for getIDS
      
      var t = db.fts_case_sensitive_nul;
      t.drop();
      
      t.ensureIndex({a: 'text'});
      t.insert({_id: 0, a: 'keyboard\0mouse'});
      
      var res = t.find({$text: {$search: 'keyboard\0mouse', $caseSensitive: true}});
      
      // a matching document should be returned for the case sensitive query
      assert.eq(getIDS(res), [0]);
      
      Show
      load('jstests/libs/fts.js'); // for getIDS var t = db.fts_case_sensitive_nul; t.drop(); t.ensureIndex({a: 'text'}); t.insert({_id: 0, a: 'keyboard\0mouse'}); var res = t.find({$text: {$search: 'keyboard\0mouse', $caseSensitive: true}}); // a matching document should be returned for the case sensitive query assert.eq(getIDS(res), [0]);

      Case sensitive text searches fail to match terms that contain embedded NUL characters.

      The behavior is inconsistent across $caseSensitive: true and $caseSensitive: false, even if the documents and queries use the same casing:

      > t.insert({_id: 0, a: 'keyboard\0mouse'});
      WriteResult({ "nInserted" : 1 })
      
      > t.find()
      { "_id" : 0, "a" : "keyboard\u0000mouse" }
      
      // the document is returned with a case insensitive search
      > t.find({$text: {$search: 'keyboard\0mouse', $caseSensitive: false}});
      { "_id" : 0, "a" : "keyboard\u0000mouse" }
      
      // no document is returned with a case sensitive search
      > t.find({$text: {$search: 'keyboard\0mouse', $caseSensitive: true}});
      > // no results
      

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            kamran.khan Kamran K.
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: