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)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 3.4.9
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      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

      Description

      Environment: windows 64 bit.

      Not all regex expressions consider the collation of a specified collection

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: