[JAVA-1114] Regular Expression on IPAddress format like does not work as expected Created: 17/Feb/14 Updated: 16/Jul/15 Resolved: 10/Mar/14 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Query Operations |
| Affects Version/s: | 2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Sridhar | Assignee: | Ross Lawley |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
2.4 & Above |
||
| Backwards Compatibility: | Fully Compatible |
| Description |
|
I am using Mongo 2.4.9, and I use simple search for my application for IPAddress search. I give search some thing like: "192.168.1.1*" , but it returns even with IP Address starting from 192.168.2* and 192.168.4* which are in my db. It has to respond only with 192.168.1.1*. details of execution is below and it would be really great help if I know which version of latest MONGO has a fix for this kind of issue if at all be raised by some one already and have been fixed. If not fixed this is the major bug for my release this week. Query: { "$and" : [ { "ipAddress" : { "$regex" : "192.168.1.*"}}]}, Fields: null, Sort: null |
| Comments |
| Comment by Ross Lawley [ 10/Mar/14 ] | |
|
Hi there, This Jira project is intended only for issues with the MongoDB Java driver. The question you are asking here is more appropriate for our users group, which you can find here: https://groups.google.com/forum/#!forum/mongodb-user. I did notice that your query didn't match the listed example eg: matching all documents 192.168.1.1* the example given is checking 192.168.1*. As you are working with regular expressions and you want to search against a string that contains dots you should escape them as in regular expressions dots match almost any character. eg:
Thanks, Ross |