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

Regular Expression Query Limitations

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.3.0
    • 2.0.1, 2.1.1
    • Querying
    • None
    • Linux, Mac OS X
    • ALL

    Description

      Querying MongoDB with a regular expression exceeding 32764 characters in length silently fails without returning any results or raising any errors.

      An example of this behaviour is as follows.

      Create a document in the mongo shell:

        > String.prototype.repeat = function(n) { return new Array(n + 1).join(this) }
        function (n) {
            return (new Array(n + 1)).join(this);
        }
        > db.example.insert({ field : "x".repeat(50000) })

      Querying for the document with a 32764 character regular expression will return a result as expected:

        > db.example.find({ field : { $regex : "x".repeat(32764) }})
        > { "_id" : ObjectId("4f9e1678d3eff3503675d2be"), "field" : "..." }

      Querying for a document with a 32765 character regular expression fails with no errors nor results:

        > db.example.find({ field : { $regex : "x".repeat(32765) }})
        >

      As per Eliot on the mongodb-user list:

      "That looks like the default pcre max size.
      Can you open a ticket @ jira.mongodb.org to see if its possible to
      increase the size?"

      Attachments

        Activity

          People

            randolph@mongodb.com Randolph Tan
            cspencer Cory Spencer
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: