[SERVER-1174] Regular expression querying doesn't work for numbers Created: 29/May/10  Updated: 25/Sep/10  Resolved: 29/May/10

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

Type: Bug Priority: Trivial - P5
Reporter: Alex Sharp Assignee: Eliot Horowitz (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

osx


Participants:

 Description   

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" }

 Comments   
Comment by Alex Sharp [ 25/Sep/10 ]

Completely understand. Thanks Elliot.

Best,

Alex Sharp

On May 29, 2010, at 7:00 PM, "Eliot Horowitz (JIRA)"

Comment by Eliot Horowitz (Inactive) [ 29/May/10 ]

We've thought about this, but don't think allowing regex against non string fields is a great idea.
It will be very slow, and kind of misleading.

Generated at Thu Feb 08 02:56:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.