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

Regular expression querying doesn't work for numbers

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      osx

      Using the regular expression search syntax on an number/integer field does not return expected results. This may well be the correct behavior. I suppose I assume that Mongo stores and queries all fields as if they were strings, which I do not believe is the case. However, it would be nice if you are doing a regular expression query on a number field, it returned results as if it were a string.

      Example:
      Sample document:

      { "_id" : ObjectId("4bc3a418091c351776000016"), "request_method" : "get", "request_uri" : "/patients/359/documents", "request_time" : "Mon Apr 12 2010 15:52:08 GMT-0700 (PDT)", "status" : 200 }

      Query that returns no results: db.collection.find(

      {status: /200/}

      )

      However, if the status field were stored as a string, then the above query would return results:

      { "_id" : ObjectId("4bc3a418091c351776000016"), "request_method" : "get", "request_uri" : "/patients/359/documents", "request_time" : "Mon Apr 12 2010 15:52:08 GMT-0700 (PDT)", "status" : "200" }

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            ajsharp Alex Sharp
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: