[SERVER-17811] Case sensitive text queries do not match terms with embedded NUL characters Created: 30/Mar/15  Updated: 06/Dec/22  Resolved: 02/Aug/19

Status: Closed
Project: Core Server
Component/s: Text Search
Affects Version/s: 3.1.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kamran K. Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 0
Labels: 32qa, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-17437 Case-sensitive mode for text search Closed
Assigned Teams:
Query
Operating System: ALL
Steps To Reproduce:

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]);

Participants:

 Description   

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



 Comments   
Comment by David Storch [ 02/Aug/19 ]

This issue appears to have been fixed:

MongoDB Enterprise > t.drop();
false
MongoDB Enterprise > t.ensureIndex({a: 'text'});
{
	"createdCollectionAutomatically" : true,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"commitQuorum" : 1,
	"ok" : 1
}
MongoDB Enterprise > t.insert({_id: 0, a: 'keyboard\0mouse'});
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise > t.find({$text: {$search: 'keyboard\0mouse', $caseSensitive: true}});
{ "_id" : 0, "a" : "keyboard\u0000mouse" }
MongoDB Enterprise > t.find({$text: {$search: 'keyboard\0mouse', $caseSensitive: false}});
{ "_id" : 0, "a" : "keyboard\u0000mouse" }

Closing as Gone Away.

Generated at Thu Feb 08 03:45:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.