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

Mongod inconsistency of regex evaluation on WiredTiger (3.4.6, 3.4.9)

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.9
    • Component/s: None
    • Labels:
      None
    • ALL
    • Hide

      Steps to reproduce.
      crate a collection with collation that has a "caseLevel" : false

      db.createCollection("comments",
      	{
      		"collation": {
      		"locale": "de",
      		"caseLevel": false,
      		"caseFirst": "off",
      		"strength": 2,
      		"numericOrdering": false,
      		"alternate": "non-ignorable",
      		"maxVariable": "punct",
      		"normalization": false,
      		"backwards": false,		
      		}
      	}
      )
      

      Insert two documents

      db.comments.insert({"text":"Abcdefghij"})
      db.comments.insert({"text":"abcdefghijXyz"})
      
      db.comments.find() // returns
      { "_id" : ObjectId("59c5161c3f1fff167ea2a5fc"), "text" : "Abcdefghij" }
      { "_id" : ObjectId("59c5161c3f1fff167ea2a5fd"), "text" : "abcdefghijXyz" }
      

      Run a simple regex query:

      > db.comments.find({"text": /cde/}) // returns
      { "_id" : ObjectId("59c5161c3f1fff167ea2a5fc"), "text" : "Abcdefghij" }
      { "_id" : ObjectId("59c5161c3f1fff167ea2a5fd"), "text" : "abcdefghijXyz" }
      

      The result makes sence, since the collection has a collation which is case insensitive, so the sever "complement" the regex to be case insensitive.

      Run another query that has two expressions:

      db.comments.find({"text": /cde/, "text": /jxy/}) // returns no documents
      

      Run a "modified" query that includes a case insensitive flag on the second expression:

      db.comments.find({"text": /cde/, "text": /jxy/i}) // returns:
      { "_id" : ObjectId("59c5161c3f1fff167ea2a5fd"), "text" : "abcdefghijXyz" }
      

      It looks like that when the sever evaluates the second expression the collation of the collection does not come into consideratin.

      This behavior was tested on windows 64 bit versions 3.4.6 and 3.4.9

      Show
      Steps to reproduce. crate a collection with collation that has a "caseLevel" : false db.createCollection("comments", { "collation": { "locale": "de", "caseLevel": false, "caseFirst": "off", "strength": 2, "numericOrdering": false, "alternate": "non-ignorable", "maxVariable": "punct", "normalization": false, "backwards": false, } } ) Insert two documents db.comments.insert({"text":"Abcdefghij"}) db.comments.insert({"text":"abcdefghijXyz"}) db.comments.find() // returns { "_id" : ObjectId("59c5161c3f1fff167ea2a5fc"), "text" : "Abcdefghij" } { "_id" : ObjectId("59c5161c3f1fff167ea2a5fd"), "text" : "abcdefghijXyz" } Run a simple regex query: > db.comments.find({"text": /cde/}) // returns { "_id" : ObjectId("59c5161c3f1fff167ea2a5fc"), "text" : "Abcdefghij" } { "_id" : ObjectId("59c5161c3f1fff167ea2a5fd"), "text" : "abcdefghijXyz" } The result makes sence, since the collection has a collation which is case insensitive, so the sever "complement" the regex to be case insensitive. Run another query that has two expressions: db.comments.find({"text": /cde/, "text": /jxy/}) // returns no documents Run a "modified" query that includes a case insensitive flag on the second expression: db.comments.find({"text": /cde/, "text": /jxy/i}) // returns: { "_id" : ObjectId("59c5161c3f1fff167ea2a5fd"), "text" : "abcdefghijXyz" } It looks like that when the sever evaluates the second expression the collation of the collection does not come into consideratin. This behavior was tested on windows 64 bit versions 3.4.6 and 3.4.9

      Environment: windows 64 bit.

      Not all regex expressions consider the collation of a specified collection

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            itzikkg Itzhak Kagan
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: